Home > Web Front-end > JS Tutorial > How to strictly judge NaN in JavaScript

How to strictly judge NaN in JavaScript

小云云
Release: 2018-02-22 09:19:16
Original
1636 people have browsed it

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template