Home > Article > Web Front-end > How to determine NaN in JavaScript
This article mainly introduces the method of strictly judging NaN in JavaScript. It is very good and has reference value. Friends in need can refer to it
I also encountered such a question on FreeCodeCamp:
Delete all false values in the array.
In JavaScript, false values include false, null, 0, "", undefined and NaN.
For NaN judgment, JS provides the function isNaN(). However, using the isNaN() function can only determine whether the variable is non-numeric, but cannot determine whether the variable value is NaN.
So, applying the properties of NaN:
> NaN === NaN; false //永远返回false
We can use === to determine whether the variable is NaN. You only need to determine whether the variable is equal to itself. If not, the value of the variable is NaN.
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Using vue to implement How to get the id of each row in the table (detailed tutorial)
How to implement the QQ side menu using the vue mobile UI framework (detailed tutorial)
The above is the detailed content of How to determine NaN in JavaScript. For more information, please follow other related articles on the PHP Chinese website!