Availability
JavaScript 1.1; JScript 1.0; ECMAScript v1
Synopsis
isNaN(x)Arguments
x
The value to be tested.
Returns
true if
x is (or can be converted to) the special
not-a-number value; false if
x is any other value.
Description
isNaN( ) tests its argument to determine whether
it is the value NaN, which represents an illegal
number (such as the result of division by zero). This function is
required, because comparing a NaN with any value,
including itself, always returns false, so it is
not possible to test for NaN with the
== or === operators.
A common use of isNaN( ) is to test the results of
parseFloat( ) and parseInt( )
to determine if they represent legal numbers. You can also use
isNaN( ) to check for arithmetic errors, such as
division by zero.
Example
isNaN(0); // Returns false
isNaN(0/0); // Returns true
isNaN(parseInt("3")); // Returns false
isNaN(parseInt("hello")); // Returns true
isNaN("3"); // Returns false
isNaN("hello"); // Returns true
isNaN(true); // Returns false
isNaN(undefined); // Returns true
See Also
isFinite( ), NaN, Number.NaN, parseFloat( ), parseInt( )
•
Table of Contents
•
Index
•
Reviews
•
Examples
•
Reader Reviews
•
Errata
JavaScript: The Definitive Guide, 4th Edition
By
David Flanagan
Publisher
: O'Reilly
Pub Date
: November 2001
ISBN
: 0-596-00048-0
Pages
: 936
Slots
: 1
This fourth edition of the definitive reference to
JavaScript, a scripting language that can be embedded
directly in web pages, covers the latest version of the
language, JavaScript 1.5, as supported by Netscape 6 and
Internet Explorer 6. The book also provides complete
coverage of the W3C DOM standard (Level 1 and Level 2),
while retaining material on the legacy Level 0 DOM for
backward compatibility.