JavaScript Number.isNaN() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

Number.isNaN(value) returns true only when value is of type number and is NaN. It is a static method (ES2015) and does not coerce types — unlike global isNaN().

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call Number.isNaN. Start with this line.

JavaScript
Number.isNaN(value)
CallWhat it does
Number.isNaN(value)Primary signature.
Number.isNaN(...)Call with the arguments your case needs.

Built into JavaScript. Call Number.isNaN(...) on the Number constructor — no import required.

Library declarations
JavaScript
Number.isNaN(value)

Parameters

ParameterDescription
valueRequired. Any value to test

Return Value

Return ValueDescription
*true or false

JavaScript Examples

Example 1 — Detect NaN

The literal NaN and Number.NaN are the same special number value.

JavaScript
console.log(Number.isNaN(NaN));         // true
console.log(Number.isNaN(Number.NaN));  // true
console.log(Number.isNaN(37));          // false
console.log(NaN === NaN);               // false — never use ===
Try It Yourself

How It Works

  1. Literal NaN. Type is number and value is NaN → true.
  2. Number.NaN. Same IEEE NaN as the global NaN constant.
  3. Normal numbers. 37 is a finite number → false.
  4. Equality fails. NaN === NaN is always false — use Number.isNaN.

Example 2 — Invalid Operations Produce NaN

Failed math and failed parses create the NaN number value.

JavaScript
console.log(Number.isNaN(0 / 0));           // true
console.log(Number.isNaN(Number("xyz")));   // true
console.log(Number.isNaN(Math.sqrt(-1)));   // true
console.log(Number.isNaN(Infinity));        // false
Try It Yourself

How It Works

  1. Indeterminate form. 0 / 0 evaluates to NaN.
  2. Bad parse. Number("xyz") cannot become a number → NaN.
  3. Domain errors. Math.sqrt(-1) is NaN in JavaScript.
  4. Infinity is different. Use Number.isFinite to reject infinity — not isNaN.

Example 3 — No Coercion (vs Global isNaN)

Strings and undefined fail with Number.isNaN, but pass with the global function.

JavaScript
console.log(Number.isNaN("NaN"));    // false
console.log(isNaN("NaN"));           // true  — coerces to NaN

console.log(Number.isNaN(undefined)); // false
console.log(isNaN(undefined));        // true  — undefined → NaN
Try It Yourself

How It Works

  1. Strict type check. "NaN" is a string → Number.isNaN returns false.
  2. Global coerces. isNaN("NaN") converts to NaN first → true.
  3. undefined trap. Global treats undefined as NaN; Number.isNaN does not.
  4. Prefer the static method. Avoid surprise true results from non-numbers.

Browser & Runtime Support

Number.isNaN() is part of ES2015 and is Baseline Widely available in modern browsers and Node.js.

✓ Baseline · ES2015

Number.isNaN()

Supported in Chrome, Firefox, Safari, Edge, and Node.js for years. Safe for modern apps without a polyfill.

98% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Number.isNaN Excellent

Bottom line: Use Number.isNaN for new code. Fall back to a polyfill only if you must support very old environments.

Frequently Asked Questions

Number.isNaN(value) returns true only when value is of type number and is NaN. Example: Number.isNaN(NaN) is true; Number.isNaN("NaN") is false.
Yes. Call it on Number itself: Number.isNaN(x). Do not call it on a number instance like (5).isNaN() — that is not the Number API.
Global isNaN() coerces the argument to a number first, so isNaN("NaN") and isNaN(undefined) are true. Number.isNaN() never coerces — non-numbers always return false.
In JavaScript, NaN is the only value that is not equal to itself. NaN === NaN is false. Use Number.isNaN(x) (or the less readable x !== x) instead.
Yes. 0 / 0 evaluates to NaN, and that value is a number, so Number.isNaN(0 / 0) is true.
It is Baseline Widely available (ES2015) and supported in every modern browser and Node.js.

Next: isSafeInteger()

Learn how to check for integers that stay exact in JavaScript numbers.

isSafeInteger() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful