js赋值符号“=”的小例子

1 var obj1={x:5};
2 var obj2=obj1;
3 obj1.a=obj1={x:6};
4 console.log(obj1.a);
5 console.log(obj2.a);

 

为什么obj1.a 会是undefined呢?

为什么obj2.a会是{x:6}?

原文地址:https://www.cnblogs.com/mrszhou/p/7590271.html