在组合的情况下,子级的依然可以改变父级的prototype
来源:3-13 面向对象(二)
慕侠4287760
2018-08-21
function Parent3(){
this.name="parent3";
this.id=[2,3,4]
}
function Child3(){
this.child="child3"
Parent3.call(this);
}
Parent3.prototype.say =function(){
console.log("say something")
}
Parent3.prototype.test =[4,5,6];
Child3.prototype= new Parent3();
var child3 = new Child3();
child3.test.push(5);
var child3_1= new Child3();
//child3_1.id.push(5);
console.log(child3.test,child3_1.test);//都是4,5,6,5写回答
1回答
-
快乐动起来呀
2018-08-22
没看懂你要问的点在哪
012018-08-22
相似问题