Initial understanding:
I read somewhere that when referential data-types (objects) are assigned to a variableA, the variable contains the address of the memory of the object. And when variableA is assigned to variableB, variableB also gets a copy of this address in memory. I.e. it refers to the same object. I liked this definition.
a = {color: "red"};
b = a;
//a = {color: "red"};
console.log(a);
console.log(b);
console.log(a === b);
Looking at the snippet above confirms this idea. It looks like a copy of the address of the memory of the object that a references is stored in a. When a is assigned to b, b gets this 'address' and references the same object.
However, this falls apart when a is reinitialised (a = {color: "red"};):
a = {color: "red"};
b = a;
a = {color: "red"};
console.log(a);
console.log(b);
console.log(a === b);
I expected a === b to still return true. To me this contradicts my 'initial understanding' because surely if b got given the same address in memory that a is a 'label' to, b would 'update' and be a label of the same thing that a is a label of.
How do I revise my understanding of what's going on?