We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
运算符优先级见:MDN
var a = {n:1}; var b = a; // 持有a,以回查 a.x = a = {n:2}; alert(a.x);// --> undefined alert(b.x);// --> {n:2}
解题步骤:
这一题要考的是运算符优先级的问题,. 的运算优先级高于 =。
.
=
a
x
a,b
{n: 2}
所以结果为:
a = {n:2}; b = {n:1, x: {n: 2}}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
运算符优先级见:MDN
看一个例子
解题步骤:
a
中声明属性x
,此时b指向a,a,b
中都有一个未赋值的属性x
=
赋值操作,a 首先被重新指向{n: 2}
{n: 2}
重新赋值给步骤1中创建的x
所指向的内存地址,由于 a 已经被重定向,所以对x的赋值操作只会影响b,而不会影响a所以结果为:
The text was updated successfully, but these errors were encountered: