来个原生的函数
class Parent{
constructor(name, number){
this.name = name;
this.number = number;
return {
number:number;
}
}
}
class Child{
constructor(name,age,number){
super(name,number);
this.age = age;
}
}
ES5会把它编译成这样
Child = (function(Person){
//inherit child__proto__ from person,…
inherit(child, person);
function child(name, age,number){
//checkifcallBynew
_this = checkpersonifreturn(this, Object.getPrototypeof(child).call(this, name, number));
_this.age = age;
return this;
}
}
)(person)
inherit(child, person)
{
child.prototype = Object.create(object.prototype, {enumerable:false, writable, true, configurable, true})
child.proto = person;
}
//person-return无返回值默认为undefined
checkpersonifretuurn(this, person_return){
-
return typeof person_return === object ||typeof person__return === function ?person_return
- this
}