[Solved] reading / assigning reference types in JavaScript


If you copy the value, then you copy a reference to the object.

If you do anything else with it, then the reference is followed and the object worked with.


The value of o is a reference to an object.

If you assign o to p then you copy that reference and p is also a reference to the object.

If you access o.foo then you follow the reference to the object and do something with the foo property of it.

If you pass o to a function, then you copy the reference to the parameter in the function. If that function then accesses paramater.foo then it follows the reference to the object and does something with the value of foo on it.

solved reading / assigning reference types in JavaScript