Reference: http://www.iteye.com/topic/785445
https://segmentfault.com/q/1010000002637728
This is a problem
1 var a = {N:1};//a points to a piece of address {n:1}; 2 var b = A; Hold A to check back //b's reference to a, also point to the address {n:1}; 3 a.x = a = {N:24 //5 // --- {N:2}
JS assignment is right-associative, starting from the right to the left to assign values
1 // equivalent to 3 A1 = (A2 = A3)4// so all are A3 values
The problem above is that:
A.x=a={n:2};
False conjecture: A first assignment {n:2},a.x discovery A is overridden (before a is {a:1}), a.x = {N:2} engine restricts a.x assignment, ignored. (because b.x has output)
Previous status:
After assignment:
That is to say, a.x still points to the previous address, and a point to a new address {N:2}, which no longer points to the previous address. If there is no B, the value of the a.x is not found (but it exists, but there is no pointer pointing to it).
A.x points to the previous address because: . operator precedence over = assignment Operation
1. First declare the x attribute of the A object (A to {n:1})
2. Assign a value to a, point to {N:2}
3, then the a.x assignment (the original A, that is, b)
In addition, a global variable appears with the use of a hyphen symbol.
1 (function() {2var a=b=1; 3 } ())4//1 becomes global variable 5//error, because there is no
JS even assignment