TIL: In JavaScript, isNaN("") returns false, but parseInt("") returns NaN. o_o

comments

isNaN returns true if the provided object is a Number, and equivalent to NaN.

No, that’s Number.isNaN. The global isNaN, which I used in the post, converts the supplied value to a number if it isn’t already, but it has such odd rules for doing so that the Mozilla web docs have an entire section talking about it.

(Also, “equivalent to NaN" is an odd phrase to use in this context; in JavaScript, NaN != NaN.)

[NaN].includes(NaN) // true
[NaN].indexOf(NaN) // -1

isNaN(parseInt("")) == true

In that case you can use Number.isNaN since you’ll be passing in a number anyway