DRAFT
EqualityOperatorComparesObjectsValues
Incorrect
The equality operator compares two objects' values
Correct
The equality operator compares two objects' references
CorrectionHere is what's right.
Here is what's right.
Consider the following code:
If the equality operator ==
compared objects looking at their values, it would conclude that obj1
is equal to obj2
. But that is not what happens: the comparison is made between the two references contained in the two variables. As the two references refer to two distinct objects in memory, the comparison returns false
.
Language
JavaScript
Concepts
Related Misconceptions
AssignmentCopiesObject
Parallel (also about reference vs. value)ObjectAsParameterIsCopied
Parallel (also about reference vs. value)