I’m down a rabbit hole. I understand that NaN cannot equal itself, hence the birth of the
isNaN('hello' / 2); // true isNaN(2) // false
I also understand that
isNaN() first coerces the value you pass it, and then it sees if the value is
However, I keep reading about the “pitfalls” of
isNaN(), and here is the one that is always referenced:
isNaN('hello') // true
How is that bad behavior? I thought a string, in this case,
'hello', is indeed not a number?
So, often times, the article points to this as the solution:
Number.isNaN('hello') // false
But, tell me, why is that better? A string isn’t a number! How does this solve anything?