function test() {
var a = {
n: 1
};
var b = a;
a.x = a = {n: 2};
console.log(a.x); //undefined
console.log(b.x); //{n:2}
console.log(a)
}
test()
a.x是属性访问,优先级比较高,那么赋值的话先把{n:2}赋给a,a的地址变化,那么a.x中的a不是地址也变了吗,在把{n:2}赋给a.x为何a.x还是undefined
相关分类