[X]

A List Equals A String

luljs still works

A shopping list can equal a string it never looked like.

In 2026: Still works. Comparing an array with == against a string coerces the array to its join, so ["milk", "eggs"] becomes "milk,eggs" and matches. An array holding one null or undefined joins to "", so [null] == "" is true.

Where it came from: Under ==, an array is converted to its comma-joined string before comparison; a wtfjs staple. wtfjs

<script>
document.write('<p><code>["milk", "eggs"] == "milk,eggs"</code> is <b>' + (["milk","eggs"] == "milk,eggs") + '</b></p>');
document.write('<p><code>[null] == ""</code> is <b>' + ([null] == "") + '</b></p>');
document.write('<p>Under ==, the array becomes its comma-joined string first.</p>');
</script>
sandboxed demo · breaks nothing but itselfrestart

More in luljs

all 63 in luljs › · the whole library ›