[X]

Two Empties Are Not Equal

luljs still works

Two identical-looking objects are never equal.

In 2026: Still works. Objects and arrays compare by reference, not contents. [] === [] is false and ({}) === ({}) is false, because each literal makes a new object. Only the very same object equals itself, which is why deep comparison needs a helper.

Where it came from: Objects compare by identity, not structure, so two separate literals are never equal. JavaScript Garden's equality section explains reference comparison. JavaScript Garden

<script>
document.write('<p><code>[] === []</code> is <b>' + ([] === []) + '</b></p>');
document.write('<p><code>({}) === ({})</code> is <b>' + (({}) === ({})) + '</b></p>');
var a = []; document.write('<p><code>a === a</code> is <b>' + (a === a) + '</b> (the very same array)</p>');
</script>
sandboxed demo · breaks nothing but itselfrestart

More in luljs

all 63 in luljs › · the whole library ›