function AAA() {
this.name = "AAA name";
}
function BBB() {
}
BBB.prototype = new AAA();
var bbb = new BBB();
var ccc = new BBB();
console.log(bbb.name); \\AAA name
console.log(ccc.name); \\AAA name
bbb.name = "111";
console.log(bbb.name); \\111
console.log(ccc.name); \\AAA name
这不是原型链继承吗?为什么修改了bbb.name
后,ccc.name
不一起改变呢?
相关分类