Home > Article > Web Front-end > How to strictly judge NaN in JavaScript
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.
Related recommendations:
Detailed explanation of usage examples of undefined, null, NaN, etc. in javascript
Articles about is_nan Recommend 4 articles
Detailed explanation of the judgment of Inf and Nan in Python
The above is the detailed content of How to strictly judge NaN in JavaScript. For more information, please follow other related articles on the PHP Chinese website!