What is NaN in JavaScript?

NaN means “Not a Number”. It is the result of a maths operation that has no valid number as result.

console.log(Number("abc"));
console.log(0 / 0);
console.log(NaN === NaN);
console.log(Number.isNaN(NaN));
console.log(typeof NaN);

Output:

Tutorials Class - Output Window

NaN
NaN
false
true
number

NaN is the only value that is not equal to itself, so check it with Number.isNaN(). Its type is number.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.