This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

isNaN

Summary

Determines whether a supplied number is NaN (not a number).

Syntax

isNaN(numValue)
numValue
Required. the value to be tested against NaN

Return Value

true if the value, converted to the Number type, is the NaN; otherwise false.

Examples

isNaN(100); // false
isNaN("100"); // false
isNaN("ABC"); // true
isNaN("10C"); // true
isNaN("abc123"); // true
isNaN(Math.sqrt(-1)); // true

Remarks

You typically use this method to test return values from the parseInt and parseFloat functions.

Alternatively, a variable that contains NaN or another value could be compared to itself. If it compares as unequal, it is NaN. This is because NaN is the only value that is not equal to itself.

See also

Other articles

Attributions

  • Microsoft Developer Network: Article