Mega Code Archive

 
Categories / JavaScript Tutorial / Number Data Type
 

NaN stands for Not a Number

NaN is an odd special value. In general, this occurs when conversion from another type fails. NaN cannot be used in mathematical calculations. NaN is not equal to itself. alert(NaN == NaN);    //outputs "false" It is not recommended to use the NaN value itself. Instead, you can use the function isNaN(). alert(isNaN("blue")); alert(isNaN("123"));