What is NaN in JavaScript?

Answer

NaN (Not a Number) is a special value of the Number type that represents the result of an operation that should return a number but cannot produce a meaningful numeric result. Examples: parseInt("hello"), 0 / 0, Math.sqrt(-1), undefined + 1. The peculiarity of NaN is that it is the only value in JavaScript that is not equal to itself: NaN === NaN is false. To check if a value is NaN, use Number.isNaN(value) (strict — only returns true for actual NaN values, not for non-numeric strings) or isNaN(value) (coerces to number first, then checks — so isNaN("hello") is true). typeof NaN === "number" — NaN is ironically of type number.