[X]

The null Comparison Paradox

luljs still works

null is not greater than zero, not equal to zero, yet null >= 0 is true.

In 2026: Still works. null == 0 is false, because == has a special rule that null equals only null and undefined. But null >= 0 uses the relational algorithm, which coerces null through ToNumber to 0, so 0 >= 0 is true. The two comparison families treat null by completely different rules.

Where it came from: == gives null its own special case while the relational operators coerce it to 0, so >= and == disagree. MDN's greater-than-or-equal page documents the numeric coercion. MDN

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

More in luljs

all 63 in luljs › · the whole library ›