doubledenial @doubledenial

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

Jul 30, 2022, 5:40 PM
5
View all Parent

comments

Highlighted comment

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.)