X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

JavaScript isNaN() Function

Function Reference JavaScript Global Functions

Example

Check whether a number is an illegal number:

var a = isNaN(123) + "<br>";
var b = isNaN(-1.23) + "<br>";
var c = isNaN(5-2) + "<br>";
var d = isNaN(0) + "<br>";
var e = isNaN("Hello") + "<br>";
var f = isNaN("2005/12/12") + "<br>";

var res = a + b + c + d + e + f;

The result of res will be:

false
false
false
false
true
true

Try it yourself »


Definition and Usage

The isNaN() function determines whether a value is an illegal number (Not-a-Number).

This function returns true if the value is NaN, and false if not.


Browser Support

Function
isNaN() Yes Yes Yes Yes Yes


Syntax

isNaN(value)

Parameter Values

Parameter Description
value Required. The value to be tested

Technical Details

Return Value: A Boolean. Returns true if the value is NaN, otherwise it returns false
JavaScript Version: 1.0


Function Reference JavaScript Global Functions

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook