15.1.2.4 isNaN(number)

2010-07-03

boolean isNaN(number:number)

Simply returns true if the argument coerces to NaN and false otherwise.

Code: (Meta Ecma)
function(number){
var n = ToNumber(number);
return n !== n; // see below
}

The specification notes that a reliable way to for Ecmascript to test whether a variable is NaN is to check x !== x. It says this can only be false if x is a NaN. Remember that NaN is the only value that is not equal to itself. The identity check ensures coercion can't screw this assumption up.