I'd rather think of variables with objects as pointers to objects (like C pointers) rather than references.
In your third line, you just replaced objA
, making it "point to" another object. It does not change whatever objB
is "pointing".
By line 3, objA
now points to {a:2}
while objB
still points to whatever objA
was pointing at the time you assigned it to objB
, at line 2, which is {a:1}
.
line 1: objA -> {a:1}
line 2: objA -> {a:1} <- objB
line 3: objA -> {a:2}, objB -> {a:1}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…