合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
>[danger]寄生组合继承实现 ---- 寄生继承就是不用实例化父类了,直接实例化一个临时副本实现了相同的原型链继承 ~~~ // 专业负责继承的, 替代继承的过程 function inheritPrototype(childFunction, fatherFunction){ childFunction.prototype = Object.create(fatherFunction.prototype); } function Person(){ this.name = "person"; this.grade = { math: 0 } } function Student() { Person.apply(this); } inheritPrototype(Student, Person); // 子类原型等于new Person(), 而new Person()出来的对象的原型等于它父类的原型 ~~~ > Object.create()方法创建一个新对象,使用现有的对象来提供新创建的对象的 \_\_proto\_\_