NaN  Number  class propertyS2C Home  « Globals « Number « NaN


NaN is returned from functions where parsing to a number fails or from Math functions where a numeric result can't be derived or is unobtainable.

  • The Nan global property is also unique in JavaScript in the fact that you cannot rely on the equality (==) and strict equality (===) comparison operators to find out whether a value is Nan or not. For this reason we have the isNan() global function which we can use to determine whether a value is Nan or not.


Signature Description
NaNGlobal property that represents the value Not-A-Number.



Below are some examples showing comparisons of NaN and an unobtainable result.

// NaN.
var nanValues = new Array(4);
nanValues[0] = NaN == NaN; // NaN not equal
nanValues[1] = NaN === NaN; // NaN not strict
nanValues[2] = isNaN(NaN); // check against isNaN
nanValues[3] = Number.POSITIVE_INFINITY * 0; // unobtainable 

Press the button below to action the above code:

Related Tutorials

JavaScript Advanced Tutorials - Lesson 3 - Number

go to home page Homepage go to top of page Top