Regarding reference types, value assignment is just a copy of the heap memory, that is, multiple variables point to the same heap memory. But under chrome, when I was testing, I encountered such a situation, I hope the experts can give me an answer
In the picture below
I created a variable a and assigned an empty object to it
Assign variable a to variable b
aAppend an attribute name
aLogout
According to the use of reference types, when a is canceled, the object should no longer exist, but b still has this reference. My question is this, shouldn't the result output by b be null, right?
高洛峰2017-05-19 10:46:03
For example:
a = {}; If the name of {} in memory is 0x2334c;
b = a; the actual execution is b = 0x2334c;
a = null; the execution is to mark a and wait for destruction;
But b still refers to 0x2334c, so 0x2334c is not destroyed;
Unless b and a = null;
滿天的星座2017-05-19 10:46:03
a and b both point to the same address c. Setting a=null only makes a no longer point to c. It does not destroy the data of c. However, b still points to c. There is nothing wrong