I’ve only been trying it in Firefox’s JavaScript console, but neither of the following statements return true:
parseFloat(\'geoff\') == NaN;
parseFloat(\'ge
The rule is:
NaN != NaN
The problem of isNaN() function is that it may return unexpected result in some cases:
isNaN('Hello') //true
isNaN('2005/12/12') //true
isNaN(undefined) //true
isNaN('NaN') //true
isNaN(NaN) //true
isNaN(0 / 0) //true
A better way to check if the value is really NaN is:
function is_nan(value) {
return value != value
}
is_nan(parseFloat("geoff"))