[X]

Non-Transitive ==

luljs still works

A equals B and A equals C, but B does not equal C.

In 2026: Still works. 0 == "" is true and 0 == "0" is true, because == coerces the strings to numbers. But "" == "0" compares two strings directly, with no coercion, so it is false. Loose equality breaks the basic rule of transitivity, which is the whole reason === exists.

Where it came from: A textbook consequence of the == algorithm coercing across types but comparing same-type operands directly, laid out on MDN's equality page. MDN

<script>
document.write("<p><code>0 == \"\"</code> is <b>" + (0 == "") + "</b></p>");
document.write("<p><code>0 == \"0\"</code> is <b>" + (0 == "0") + "</b></p>");
document.write("<p><code>\"\" == \"0\"</code> is <b>" + ("" == "0") + "</b></p>");
</script>
sandboxed demo · breaks nothing but itselfrestart

More in luljs

all 63 in luljs › · the whole library ›