Home>Article>Web Front-end> What is isNaN in javascript

What is isNaN in javascript

藏色散人
藏色散人 Original
2022-01-18 11:40:05 6757browse

javascript's isNaN is a built-in function used to check whether its parameter is a non-numeric value. Its usage syntax is "isNaN(value)", and the parameter value specifies the value to be detected.

What is isNaN in javascript

The operating environment of this article: Windows 7 system, javascript version 1.8.5, Dell G3 computer.

What is isNaN of javascript?

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

If the parameter value is NaN or a non-numeric value such as a string, object, or undefined, it will return true, otherwise it will return false.

Syntax

isNaN(value)

Parameters

value required. The value to detect.

All major browsers support isNaN() function

Example

Check whether the number is illegal:

document.write(isNaN(123)+ "
"); document.write(isNaN(-1.23)+ "
"); document.write(isNaN(5-2)+ "
"); document.write(isNaN(0)+ "
"); document.write(isNaN("Hello")+ "
"); document.write(isNaN("2005/12/12")+ "
");

The output result of the above example:

false false false false true true

Recommended learning: "js Basic Tutorial"

The above is the detailed content of What is isNaN in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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