Inadvertently found on the Internet, the expected results and the actual results are very different.
var a={n:1}var b=a;a.x=a={n:2}console.log (a.x); Console.log (b.x) ;
undefinedobject{n:2}
If you take it apart, the result is what I think.
var a={n:1}var b=a;a={n:2};a.x={n:2}console.log (a.x);// Object{n:2}
Console.log (b.x);//undefined
Analysis:
A.x=a={n:2}
JS assignment is right-associative, which equates to a.x= (A={n:2})
JS evaluation operation is from left to right (PS: and colleagues discuss, he said is from left to right, I think is from right to left, finally found that I was wrong)
1) a.x= (the final result in parentheses)
Find the x attribute of a does not exist after adding an attribute x to the object a points to, the X attribute to assign a result to it, well, I'm waiting for the result.
2) because it is to get the result in parentheses, then a.x has been waiting for him to return the result in parentheses, so start to evaluate A={n:2} to get the result back to the new attribute X
3) Back in parentheses the a={n:2},a happened to point to change the
JS Continuous Assignment