Home > Web Front-end > JS Tutorial > body text

JavaScript uses the isNaN() function to determine whether a variable is a number_javascript tips

WBOY
Release: 2016-05-16 17:22:14
Original
1653 people have browsed it

How to determine whether a variable is a number in javascript. Here we mainly introduce the isNaN() function in javascript.

Function:

isNaN() function is used to check whether its argument is a non-numeric value.

Syntax:

isNaN(x) x required. The value to detect.

Return value:

If x is the special non-numeric value NaN (or can be converted to such a value), the returned value is true. If x is any other value, returns false.

Explanation:

isNaN() function can be used to determine whether its parameter is NaN. This value represents an illegal number (such as the result obtained after dividing by 0) .
If NaN is compared with any value (including itself), the result is false, so to determine whether a value is NaN, you cannot use the == or === operators. Because of this, the isNaN() function is required.

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!