var a = {"x": 1};
var b = a;
console.log(b.x);
a.x = 2;
console.log(b.x);
a = {"x":3};
console.log(b.x);
a.x = 4;
console.log(b.x);
上面四项输出打印a.x,输出结果分别是1 2 2 2
问题:
1.对象赋值是引用传递,但是var a = {"x": 1},等价于var a = {x: 1}吗?字符串做堆的指向栈?引用用可以用字符串来访问?
能不能分别解释一下上面四项输出?
慕尼黑8549860
相关分类