分析:
后面的代码用child函数创建的对象的原型对象是 child1.prototype=o1{a:1,b:[1,2,1],c:{demo:5},show:上面的函数,__proto__:o3{}}
parent=o2{a:1,b:[1,2,1],c:{demo:5},show:上面的函数,__proto__:o3{}}
child2={a:12,change:上面的函数,__proto__:o1}
child1={a:11,change:上面的函数,__proto__:o1}
运行Parent()函数 console.log(this.a, this.b, this.c.demo);===>parent就是this也是o2对象
o2.a==>1 o2.b===>[1,2,1] o2.c.demo====>5
1 [1,2,1] 5
show函数是原型对象的方法 child1自己没有 访问原型的 就是调用者(函数内部的this)就是child()
====>console.log(this.a, this.b, this.c.demo);
this.a===>11 this.b===>[1,2,1] this.c.demo====>5
11 [1,2,1] 5
show函数是原型对象的方法 child2自己没有 访问原型的 就是调用者(函数内部的this)就是child()
====>console.log(this.a, this.b, this.c.demo);
this.a===>12 this.b===>[1,2,1] this.c.demo====>5
12 [1,2,1] 5
//this是child1
this.b.push(this.a);
b是原型对象的属性,但是它没有修改B,只是操作了b内部的数据是可以让原型对象的内部对象改变this.a取值会优先取原型链顶层的数据11==>原型对象的数组中添加11
this.a = this.b.length;
给child自己添加a属性 值为4 child1的原型对象的属性b的长度
this.c.demo = this.a++;
this.c。demo=先取值4 再把a的值加一
this.c属性是原型对像的属性 但是没有修改这个属性情况下 可以操作起内部的数据
因此原型对象的c属性中的demo属性改为4
this是child2
this.b.push(this.a);
b是原型对象的属性,但是它没有修改B,只是操作了b内部的数据是可以让原型对象的内部对象改变
this.a取值会优先取原型链顶层的数据12==>原型对象的数组中添加12
this.a = this.b.length;
给child自己添加a属性 值为5 child2的原型对象的属性b的长度
this.c.demo = this.a++;
this.c.demo=先取值5 再把a的值加一
this.c属性是原型对像的属性 但是没有修改这个属性情况下 可以操作起内部的数据
因此原型对象的c属性中的demo属性改为5
运行Parent()函数 console.log(this.a, this.b, this.c.demo);===>parent就是this也是o2对象
o2.a==>1 o2.b===>[1,2,1] o2.c.demo====>5
1 [1,2,1] 5
show函数内部this是parent
====>console.log(this.a, this.b, this.c.demo);
this.a===>5 this.b====>[1,2,1,11,12] this.c.demo====>5
5 [1,2,1,11,12] 5
show函数内部this是parent
====>console.log(this.a, this.b, this.c.demo);
this.a===>6 this.b====>[1,2,1,11,12] this.c.demo====>5
6 [1,2,1,11,12] 5