Forget all the low-level nonsense about "references" (which do not exist in JavaScript) and consider the simple rules outlined below. The term "object" is used to represent a specific value, which is not necessarily an "Object"; this does not change the rules, but rather reinforces the consistency.
1) An object is itself. If an object is mutable and if that object is mutated then that object has been mutated.
2) An assignment does not create a copy/clone/duplicate of an object. This includes values "assigned" to the parameters in function calls. The object is the value.
3) A variable (or property) is not an object, rather it is a name for an object (a pretty way to say "the variable evaluates to a given object"). A single object can have many "names" and yet it is the same object.
Everything else is an implementation detail -- references are not talked about in the specifcation at all. While, it should be noted that the primitive values such as number
and string
cannot have additional properties assigned (the assignment is ignored) while the wrapper Objects Number
and String
are full-fledged objects. This is consistent with the above rules: there are no mutable non-Object values in JavaScript. For the sake of discussing the JavaScript language the primitives values can be thought of as objects although they are completely immutable and are not really Objects.
Happy coding.