[X]

[] == ![]

luljs still works

An empty array is equal to the negation of itself.

In 2026: Still works. ![] is false, because any object is truthy so its negation is false. Then [] == false triggers coercion: the boolean becomes 0, the array becomes "" and then 0, and 0 == 0 is true.

Where it came from: A canonical entry in the wtfjs collection. It combines the truthiness of objects with the coercion rules of loose equality into one contradiction. wtfjs

<script>
document.write("<p><code>![]</code> is <b>" + (![]) + "</b></p>");
document.write("<p><code>[] == ![]</code> is <b>" + ([] == ![]) + "</b></p>");
document.write("<p>Both sides collapse to 0 under == coercion.</p>");
</script>
sandboxed demo · breaks nothing but itselfrestart

More in luljs

all 63 in luljs › · the whole library ›