What does "isNaN()" mean in JS?

Hi all. I’ve know that numbers can be either integer or float.

But I don’t know how to use a function called isNaN(). I don’t know how:

console.log(isNaN("Hello")); // => true

And also what would happen if I call isNaN() function on a string that looks like a number?

console.log(isNaN('36')); // what does it evaluate to? true or false?

Please answer.


isNaN will check if a value is NaN or not

1 Like

This part confused me too. When I dug around mdn docs and stackoverflow I found this explanation.

Quote from stackoverflow answer
When the argument to the isNaN function is not of type Number, the value is first coerced to a Number. The resulting value is then tested to determine whether it is NaN.

Here is the full discussion breaking down the MDN explanation for isNaN.

Hope that helps!