The problem with javascript object.create

  node.js, question
var aa={a:1,b:[1,2,3]};
 var bb=Object.create(aa);
 var cc=Object.create(aa);
 bb.b=[1,2];
 console.log(bb.b);
 console.log(aa.b);
 cc.b.push(3);
 console.log(cc.b);
 console.log(aa.b);
 The output is as follows. Why does the value of the attribute of prototype aa not change when = is used, but push will change

clipboard.png

Object.create

It’s quite special.

var cc = Object.create(aa);
 cc instanceof aa.constructor //true
 aa.isPrototypeOf(cc) //true
 cc.hasOwnProperty('b') //false
 aa.hasOwnProperty('b') //true

*ccThey don’t have their ownbProperty, the reason it can be executed
cc.b.push(3)BecauseccYou can find thebProperty.

If this is the case,
*cc.b = [1,2]It is equivalent to adding one to yourself.bProperty, thisbYesccOwn.
At this time

cc.b = [1,2]
 cc.hasOwnProperty('b') //true