The full title reads:

var a = {n: 1};

var b = a; 

a.x = a = {n: 2};

Please output

 a.x  //undefined

B.x / / {n: 2})

Personal Understanding:

1. Assignment operation sequence:

As in js “. A.x = a={n:2}; a.x = a={n:2}; a.x ={n:2};

2. Reference Relationship:

A and b refer to the same memory address, i.e. a reference to {n: 1}, i.e. a===b;

The appearance is A.x, which is actually the attribute x of {n:1}. Due to the reason of operation order, it is first determined that A.x is actually the attribute X of {n:1} and also the attribute x of B. A and B also keep references to {n:1}. When path a={n:2}, a does not reference {n:1} because a is reassigned. Finally give a.x assignment, in fact is for {n: 1} the properties of the x value assignment, this time b also to keep {n: 1} references, so the final output:

A.x = {n:2} attribute x = undefined;

B.x = {n:1} x = a ({n:2});

If you can’t describe it, please correct it.

— the end —