Number.isNaN vs isNaN Playground

Members’ deposits arrive as text and are checked before they are added: global isNaN, Number.isNaN, or x === NaN. Which check really stops an entry in words…

Why it matters

A check for "is this a number?" is often written with isNaN, and it refuses or lets through the wrong things: undefined, empty text, words. One NaN that slips through spreads to every sum after it.

The key idea

isNaN asks "turned into a number, is it NaN?", Number.isNaN asks "is this NaN?"

Common mistakes

Try it in this playground