组合继承的优化2
来源:3-13 面向对象(二)

慕的地3168188
2017-09-12
function Parent5(){
this.name = 'parent5';
this.play = [1,2,3];
}
function Child5(){
Parent5.call(this);
this.type = 'child5';
}
Child5.prototype = Object.create(Parent5.prototype);
var test1 = new Child5()
console.log(test1.__proto__) //Parent5, 并没有指向Child5
写回答
2回答
-
慕的地3168188
提问者
2017-09-12
test1.__proto__ === Child5.prototype //true
00 -
慕的地3168188
提问者
2017-09-12
是我没有看完视频,老师也讲到了需要手动指定constructor
Child5.prototype.constructor = Child5
没有疑问
00
相似问题