That's how the equality algorithm has been specified (sec 11.9.3):
The comparison x == y, where x and y are values, produces true or false. Such a comparison is performed as follows:
- If
Type(x)
is the same as Type(y)
, then
- [...]
- Return
true
if x
and y
refer to the same object. Otherwise, return false
.
So the following will return true and all other equality comparisons will return false
var x = [1,2,3];
return x == x;