[X]

NaN Batman

luljs 2012 still works

Subtract a number from a word, repeat it across an array, and out comes the Batman theme.

In 2026: Still evaluates the same everywhere. 'wat' - 1 forces a number and fails, giving NaN, which join turns into the text "NaN". Array(16) has fifteen gaps between elements, so join lays down fifteen copies of NaN before the tail, producing the word NaN fifteen times over followed by " Batman!".

Where it came from: Gary Bernhardt's 'Wat' lightning talk, CodeMash 2012, on destroyallsoftware.com. Its closing line. MDN

<script>
var s = Array(16).join('wat' - 1) + ' Batman!';
document.write("<h2 style='font-family:sans-serif'>" + s + "</h2>");
document.write("<p><code>Array(16).join('wat' - 1) + ' Batman!'</code></p>");
document.write("<p><code>'wat' - 1</code> is <b>NaN</b>, joined across fifteen array gaps.</p>");
</script>
sandboxed demo · breaks nothing but itselfrestart

More in luljs

all 63 in luljs › · the whole library ›