CKTIS / JavaScript
isNaN() — checking for NaN after conversion
The global isNaN(value) function first converts its argument to Number, then checks whether the result is NaN. Unlike Number.isNaN(), it can return true for strings or undefined, so it is not a general test for a valid number.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
isNaN(value)isNaN(value) is a global ECMAScript function, not a browser API. It applies the ToNumber operation to its argument and returns true if the result is NaN; otherwise, it returns false. NaN is a special value of the Number type representing a result that is not a valid number, such as the result of 0 / 0.
Conversion matters: isNaN("hello") and isNaN(undefined) return true, but isNaN("42"), isNaN(""), and isNaN(null) return false. The empty string and null convert to 0. Calling isNaN() without an argument behaves like passing undefined and returns true.
Number.isNaN(value) does not perform conversion: it returns true only for the Number value NaN. Use it when you want to check the value itself rather than its conversion result. Do not compare against NaN using ===, because even NaN === NaN produces false. A false result from isNaN does not prove that the argument is a number or that it is finite: isNaN(Infinity) also produces false.
Conversion can throw an exception instead of returning a boolean. A Symbol or BigInt argument, such as isNaN(1n), causes a TypeError. Converting an object can execute its conversion code and propagate a thrown exception. Therefore, do not treat isNaN as a safe validator for arbitrary data.
Examples
const values = [NaN, "hello", "42", "", null, undefined, Infinity];
for (const value of values) {
console.log(`${String(value)}: ${isNaN(value)} / ${Number.isNaN(value)}`);
}Result
NaN: true / true hello: true / false 42: false / false : false / false null: false / false undefined: true / false Infinity: false / false
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.