The Two Kinds Of isNaN
luljs 1997 still worksThe global isNaN coerces its argument first, so it calls an empty string a number and calls letters not-a-number.
In 2026: Still works. The global isNaN runs its argument through Number() before testing, so isNaN('') is false because Number('') is 0, while isNaN('abc') is true because Number('abc') is NaN. Number.isNaN skips the coercion and reports true only for the actual NaN value. Reach for Number.isNaN, or test x !== x.
Where it came from: Nicholas Zakas, Professional JavaScript for Web Developers, the section on isNaN and numeric coercion (around 2012). MDN ↗
<script>
function show(l, v){ document.write('<p><code>' + l + '</code> is <b>' + v + '</b></p>'); }
show('isNaN("")', isNaN(""));
show('isNaN("abc")', isNaN("abc"));
show('isNaN([])', isNaN([]));
show('Number.isNaN("abc")', Number.isNaN("abc"));
</script>