[X]

parseInt(null, 24)

luljs still works

parseInt of null in base 24 is 23.

In 2026: Still works. parseInt coerces its first argument to a string, so null becomes the text "null". In base 24 the digits run 0 to 9 then a to n, so "n" is worth 23. parseInt reads "n", stops at the first invalid character "u", and returns 23.

Where it came from: A wtfjs classic: parseInt stringifies null to "null", and base 24 makes "n" a valid digit worth 23. wtfjs

<script>
document.write('<p><code>parseInt(null, 24)</code> is <b>' + parseInt(null, 24) + '</b></p>');
document.write('<p>null becomes the string "null". In base 24, "n" is a valid digit worth 23, and parseInt stops at "u".</p>');
document.write('<p><code>parseInt(null, 10)</code> is <b>' + parseInt(null, 10) + '</b> (base 10 has no "n")</p>');
</script>
sandboxed demo · breaks nothing but itselfrestart

More in luljs

all 63 in luljs › · the whole library ›