When dealing with objects in various languages, including JavaScript, objects are almost universally passed and compared by reference, which means that an object that is passed to a method does not get copied, but rather its pointer gets passed, and when two objects are compared, their pointers are compared. This is not how we think about objects and especially value objects, as we think of those as identical if their properties are identical. More importantly, we don't want to consider the inner implementation details when we consider things like equality. This has some implications for the function using the object; one important implication is that modifying the object will actually change it for everybody in the system, for example:
function iChangeThings(obj) { obj.thing = "changed" } obj = {} obj.thing // => undefined iChangeThings(obj) obj.thing // => "changed"
Related to this is the fact that comparing does not always yield the expected result as in this case...