I know that identical objects are not equal, i.e:
var obj = { name: \"Value\" };
var obj2 = { name: \"Value\" };
console.log(\"obj equals o
This seems to really be a question about ===
so let's look at the Strict Equality Comparison Algorithm, in which point 7 says
Return
true
if x and y refer to the same object. Otherwise, returnfalse
.
So what does it mean to be "the same object"? It means they don't just look like eachother, but are at the same place in memory too. This means that the only time when an Object is ===
to an Object is when they're the same thing.
var a = {},
b = {}, // identical to `a`
c = a; // same as `a`
a === b; // false
a === c; // true
b === c; // false