P. 1
Advanced Javascript Second Edition

Advanced Javascript Second Edition

|Views: 54|Likes:
Published by harvish
the perfect guide 2 java but jsu 4 beginners. . . .
the perfect guide 2 java but jsu 4 beginners. . . .

More info:

Published by: harvish on May 26, 2010
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





The isNaN() function evaluates an argument to determine if it is not a number, or
NaN. The functions parseFloat() and parseInt() return NaN when they evaluate a
value that is not a number or a numeric string. NaN is not a number in any string. If
NaN is passed on to arithmetic operations, the result is also NaN. The isNaN() returns
a Boolean value, according to the argument. Bear in mind that Internet Explorer 3.0
does not support this feature—parseFloat() and parseInt() both return 0 if their
argument is neither a string nor a numeric string. However, this is supported in the
current version.

NaN is not a string, nor is it a data type of its own. It is primarily a number! You can
prove that to yourself via the following statement:

alert(typeof parseInt("something"))

The following construct demonstrates how to implement the isNaN function (with the
parseFloat() function for the sake of the example):

var floatValue = parseFloat(valueToBeConvertedToFloat)

if isNaN(floatValue)






Handling Strings n 269






The isNaN() function is not as important as parseInt and parseFloat, but we have
discussed it here for completeness.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->