/

HTML / CSS / JavaScript Tutorial

JavaScript Global method: isNaN()

[this page | pdf | back links]

The JavaScript Global isNaN() method returns true if the value equates to NaN (after initial conversion to a Number) otherwise returns false.

 

It has the following syntax with the following parameters:

 

isNaN(x)

 

Parameter

Required / Optional

Description

x

Required

Input parameter

 

The Number.isNaN method is subtly different to the global isNaN function. The latter coerces a value to a number before testing it, whilst the former does not. So, Number.isNaN("NaN") returns false, whilst isNaN("NaN") returns true.

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile