[X]

true + true

luljs still works

Add booleans together and they turn into numbers.

In 2026: Still works. Under arithmetic +, a boolean coerces through ToNumber, so true becomes 1 and false becomes 0. That makes true + true equal 2 and true + true + true equal 3.

Where it came from: A direct result of the ToNumber coercion that the addition operator applies to booleans, documented on MDN's addition page. MDN

<script>
document.write("<p><code>true + true</code> is <b>" + (true + true) + "</b></p>");
document.write("<p><code>true + true + true</code> is <b>" + (true + true + true) + "</b></p>");
document.write("<p><code>true * 5</code> is <b>" + (true * 5) + "</b></p>");
</script>
sandboxed demo · breaks nothing but itselfrestart

More in luljs

all 63 in luljs › · the whole library ›