Number.isNaN
Determines whether the passed value is NaN and its type is Number, providing a more robust version of the original global isNaN()
Syntax
Number.isNaN(value)Parameters
| Parameter | Type | Description |
|---|---|---|
| value | any | The value to be tested |
Return Value
true if the value is NaN and is a number, false otherwise
Examples
console.log(Number.isNaN(NaN)); // true
console.log(Number.isNaN(42)); // false
console.log(Number.isNaN('NaN')); // false// Difference from global isNaN:
console.log(isNaN('hello')); // true (coerces to NaN)
console.log(Number.isNaN('hello')); // false (strict check)const results = [1, NaN, 3, NaN, 5];
const valid = results.filter(n => !Number.isNaN(n));
console.log(valid); // [1, 3, 5]Understanding Number.isNaN
The Number.isNaN method in JavaScript determines whether the passed value is NaN and its type is Number, providing a more robust version of the original global isNaN(). It belongs to the Number object and is one of the most widely used methods for working with number values in modern JavaScript and TypeScript applications.
The method signature is Number.isNaN(value). It accepts 1 parameter: value. When called, it returns true if the value is nan and is a number, false otherwise. Understanding when and how to use isNaN() helps you write more expressive, readable code.
Common use cases for Number.isNaN include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like number-isfinite, number-isinteger, object-is, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Number.isNaN is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
More Number Methods
Other methods in the Number object
Related Tools
More Number Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.