Jump to content


From Simple English Wikipedia, the free encyclopedia

In computing, NaN stands for Not a Number. It means the result of input is or unrepresentable. For example, division by zero in most Programming language returns NaN. Systematic use of NaN was introduced by the IEEE 754 in 1985, along with the other numbers such as infinities.

In JavaScript[change | change source]

In JavaScript, NaN == NaN or NaN == other_value returns false. using === also returns false. You can use Number.isNaN(myVar) or isNaN(myVar) to check if a value is NaN. there is difference between two functions. the Number.isNaN(myVar) returns true when the value is NaN when parsed to int. but isNaN(myVar) returns true when the value is currently NaN.[1]

For example:

Number.isNaN('Hi!') // returns true because 'Hi!' in integer is NaN

isNaN('Hi!') // returns false because 'Hi!' is not NaN

References[change | change source]

  1. "NaN - JavaScript | MDN". developer.mozilla.org. Retrieved 2022-08-06.