Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
It is extremely important to grok that complex values are stored and
manipulated by reference. When creating a variable
containing a complex object, the value is stored in memory at an address.
When you reference a complex object, you’re using its name (i.e., variable
or object property) to retrieve the value at that address in memory. The
implications are significant when you consider what happens when you
attempt to copy a complex value. Below, we create an object stored in the
variable myObject. Then the value in
myObject is copied to the variable
copyOfMyObject. Really, it is not a
copy of the object—more like a copy of the address of the
object.