JavaScript Number.NaN Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

Number.NaN is the Not-A-Number value — the same IEEE-754 NaN as global NaN. It marks an invalid numeric result. It is a static property, not a method, and it never equals itself with ===.

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use Number.NaN. Start with this line.

JavaScript
Number.NaN
CallWhat it does
Number.NaNPrimary signature.

Built into JavaScript. Read Number.NaN on the Number constructor — no import required.

Library declarations
JavaScript
Number.NaN

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*The current value of Number.NaN.

JavaScript Examples

Example 1 — Read Number.NaN

Print the constant and confirm it matches global NaN.

JavaScript
console.log(Number.NaN);
console.log(Object.is(Number.NaN, NaN));
Try It Yourself

How It Works

  1. Static access. Read Number.NaN on the constructor — there is no (5).NaN.
  2. Prints as NaN. Consoles show the special Not-A-Number token.
  3. Same value. Object.is confirms it is the same as global NaN.
  4. Why Object.is? === cannot prove sameness for NaN — more on that next.

Example 2 — The Equality Trap

NaN is the only value that is not equal to itself.

JavaScript
console.log(Number.NaN === Number.NaN);  // false
console.log(0 / 0 === Number.NaN);       // false
console.log(Number.isNaN(0 / 0));        // true
Try It Yourself

How It Works

  1. Self-compare fails. Number.NaN === Number.NaN is always false.
  2. Expressions too. 0 / 0 is NaN, but === Number.NaN still fails.
  3. Use the helper. Number.isNaN(0 / 0) returns true.
  4. Rule. Never test for NaN with ===.

Example 3 — isNaN vs Number.isNaN

Global isNaN coerces; Number.isNaN does not.

JavaScript
console.log(Number.isNaN(Number.NaN));  // true
console.log(Number.isNaN("foo"));       // false
console.log(isNaN("foo"));              // true  — coerces!
Try It Yourself

How It Works

  1. Real NaN. Number.isNaN(Number.NaN) is true.
  2. Strict type. A string is not NaN → Number.isNaN("foo") is false.
  3. Global coerces. isNaN("foo") converts to NaN first → true.
  4. Prefer strict. Use Number.isNaN in new code to avoid string traps.

Browser & Runtime Support

Number.NaN is part of core JavaScript and is Baseline Widely available in modern browsers and Node.js.

✓ Baseline · Widely available

Number.NaN

Supported in Chrome, Firefox, Safari, Edge, and Node.js for decades. Same value as global NaN.

99% 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.NaN Excellent

Bottom line: Use Number.NaN freely. Pair it with Number.isNaN (ES2015) for reliable detection in modern apps.

Frequently Asked Questions

Number.NaN is the Not-A-Number value on Number. It is the same IEEE-754 NaN as the global NaN. Common sources: 0 / 0, Infinity - Infinity, Math.sqrt(-1), and Number("abc").
Yes. Read it on Number itself: Number.NaN. There is no (5).NaN on number instances, and it is not a method.
NaN is the only JavaScript value that is not equal to itself. Number.NaN === Number.NaN and Number.NaN === NaN are both false. Use Number.isNaN(x) or Object.is(x, NaN).
Prefer Number.isNaN(x). It returns true only for actual NaN. Global isNaN(x) coerces first, so isNaN("foo") is true even though "foo" is a string.
Yes — same Not-A-Number value. Object.is(Number.NaN, NaN) is true. Prefer Number.NaN when you want the constant grouped with other Number properties.
It is Baseline Widely available and supported in every modern browser and Node.js.

Next: Number Constructor

Learn how to create Number values and convert strings to numbers.

Number constructor 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.

11 people found this page helpful