Open MJingv opened 11 months ago
https://www.bilibili.com/video/BV1u4411f7gR/?spm_id_from=333.999.0.0&vd_source=7b895e5b6eb680ef380c7682a270ed8c
如何理解?
注意
const Person=function(name){ this.name=name } const a=new Person('a') a.constructor.prototype.getAge=function(age){return age+18} //通过儿子给爸爸加方法 const b=new Person('b') b.getAge(2)//女儿直接用儿子的方法 b.__proto__ // 得到原型链的方法 {getAge: ƒ, constructor: ƒ} b.__proto__.constructor // Person
https://www.bilibili.com/video/BV1u4411f7gR/?spm_id_from=333.999.0.0&vd_source=7b895e5b6eb680ef380c7682a270ed8c
如何理解?
注意