myGlobal.NaN in ECMAScript 262
Not a Number
- Property Type
- NaN
This property of the Global object is accessible directly, and is the result value of various (usually failed) mathematical operations. This is also the value of the class property Number.NaN
. However, comparison to NaN
always returns false
. (Even NaN==NaN
evaluates to false
.) To see if a value is NaN
, use the global isNaN()
function.
var result = 1 * 'cat' - 'orange';
var isNotANumber = isNaN(result); //true
var theSame = (result == NaN); //false; result is NaN, but comparing it to NaN fails
var theSame = (NaN == Number.NaN); //false; Number.NaN is NaN, but comparing it to NaN fails