Why Does JavaScript Do This!? #002

In JavaScript this

NaN === NaN

and this

NaN == NaN
are false...

Wait what? Is both of those are false... then how can we tell if something is NaN? Well there's two ways.

The first is with the `Math.isNaN()` method. This one's kind of like a '==='. It's only going to return true if you literally pass it the 'NaN' value. If you pass in a string, boolean, or number it will return False.

The second is with just the isNaN() method. This one is a little looser and more like a '=='. This will coerce values and tell if you it is NaN or not. If you pass in the string 'hi', it will try to convert it to a number, realize that it's NaN, and return true.

See the full video here - https://youtube.com/shorts/JjxP1c1tj24?si=iHRKLMBq5WYMNT3G