isNaN() (Function/global)

Test a numeric value for validity.

Availability:

ECMAScript edition - 1
JavaScript - 1.3
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2
Netscape Enterprise Server version - 2.0
Property/method value type:Boolean primitive
JavaScript syntax:-isNaN(aValueToTest)
Argument list:aValueToTestA numeric value to be tested for validity

This is a built-in function to check for the Not-a-Number value. Because it is a member of the Global object, and the Global object is permanently in the prototype inheritance chain, you don't need to identify which object the function belongs to.

Applies the internal ToNumber operator to its argument and returns true or false depending on whether the value is a number or not.

The values may not always yield the result you expect.

These all yield a false value:

These all yield a true value:

The result is true for valid numeric values and false for invalid numerics.

Warnings:

See also:Enquiry functions, Function property, Global object, NaN, Number, Special type, ToNumber

Property attributes:

DontEnum.

Cross-references:

ECMA 262 edition 2 - section - 15.1.2.6

ECMA 262 edition 3 - section - 15.1.2.4

Wrox Instant JavaScript - page - 15

Wrox Instant JavaScript - page - 28