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:
"4"
true
false
100.00
Infinity
null
These all yield a true value:
"4A"
"true"
"false"
undefined
The result is true for valid numeric values and false for invalid numerics.
This is not very useful on MSIE version 3.02 since it cannot understand what a NaN is in the first place.
Although this was added to some browsers in version 1.0 of JavaScript, it was not available in all versions of Netscape until it was added to the Unix variants for JavaScript 1.1. Most browsers being used these days are at least version 1.1 compliant so this issue is becoming less important.
Comparing the NaN value with anything using the == operator will always yield the Boolean false value.
See also: | Enquiry functions, Function property, Global object, NaN, Number, Special type, ToNumber |
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
Prev | Home | Next |
isLower() | Up | ISO 3166 |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |