阿里前端面试题

73 阅读1分钟

赋值运算的考察

var a = {n:1};
var b = a;
a.x = a = {n:2};

console.log(a.x)  //undefined
console.log(b.x)  //{n:2}

赋值运算的细节

a = 1 为例:

image-20220810121954538.png 对于前两行的内存储存情况如下:

image-20220810123456851.png

当执行到第三行时内存储存情况如下:

image-20220810124410712.png