When undefined Could Change
luljs still worksThere was a time you could set undefined to 42, which is why minifiers still write void 0.
In 2026: The relic half is dead, the habit is not. In old JavaScript undefined was an ordinary writable global, so one stray undefined = 42 anywhere poisoned every check on the page. The void operator takes any expression and returns the real undefined, so void 0 was the safe way to get it. ES5 made the global read-only in 2009, and minifiers still emit void 0 because it is shorter than the word.
Where it came from: The void operator and the history of a reassignable undefined, documented on MDN's void page. MDN ↗
<script>
document.write('<p><code>void 0 === undefined</code> is <b>' + (void 0 === undefined) + '</b></p>');
document.write('<p><code>void "anything at all"</code> is <b>' + (void "anything at all") + '</b></p>');
document.write('<p>Old engines let you reassign <code>undefined</code>. <code>void 0</code> always returned the real one.</p>');
</script>