function Person(name,age){
this.name = name
this.age = age;
}
Person.prototype.home = [1,2,3];
Person.prototype.aa =100;
var p = new Person('joy','7');
console.log(p.__proto__.home); //[1,2,3]
console.log(p.__proto__.aa); // 100
p.aa = 200;
p.home[0] = 200;
console.log(p.__proto__.home); //[200,2,3]
console.log(p.__proto__.aa); // 100
Why p.__proto__.home
was changed. In my opinion, the p.aa = 200;
has changed the p.__proto__.aa
,but it was not.
Why know the reason? Please write more details.
Which book is relevant to the content?