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

How to determine NaN in JavaScript

亚连
Release: 2018-06-05 17:36:39
Original
5627 people have browsed it

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
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.

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to implement the file segment upload function through Vue2.0 combined with webuploader (detailed tutorial)

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!

Related labels:
js
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