Objects are referenced, and when you compare two links, they return false.
another answer (given by Eamon Nerbonn) has a very important point:
Objects are considered equivalent if
- They are exactly equal for
=== (String and Number are first unpacked to ensure 42 equivalent to Number(42) ) - either they are dates and have the same
valueOf() - either they are of the same type, not null and ...
- they are not objects and are equal to
== (captures numbers / strings / booleans) - or, ignoring properties with an
undefined value, they have the same properties, all of which are considered recursively equivalent.
source share