Number.NaN is a static data property on Number (same API as MDN Number.NaN). It is the Not-A-Number value — the same as global NaN. You get it from invalid math or failed numeric conversion. The gotcha beginners hit first: x === Number.NaN is nevertrue. This tutorial covers detection with Number.isNaN, MDN patterns, five examples, and try-it labs.
01
Kind
Static property
02
Value
NaN
03
Same as
global NaN
04
Equals self?
Never
05
Writable
No
06
Baseline
Everywhere
Fundamentals
Introduction
IEEE-754 floating point includes a special value for results that are not a number — for example 0 / 0 or Math.sqrt(-1). JavaScript exposes that value as both NaN and Number.NaN.
They are the same Not-A-Number value (Object.is(Number.NaN, NaN) is true), but === still returns false because NaN is not equal to anything, including itself. Prefer Number.isNaN(x) to test for it.
💡
Static Property
Static properties belong to Number itself. Always write Number.NaN. There is no (5).NaN, and you do not call it like a function.
NaN is still a typeof"number" — it is a special floating-point bit pattern, not a string or an error object. Once a calculation becomes NaN, more math usually stays NaN (poisoning).
It is a constant number, not a method.
Same value as global NaN (Object.is).
Number.NaN === Number.NaN is always false.
Detect with Number.isNaN(x) (preferred) or Object.is(x, NaN).
Foundation
📝 Syntax
General form of the static property Number.NaN:
JavaScript
Number.NaN
Value
The number value NaN (Not-A-Number) — same as the global NaN property.
Property attributes
Attribute
Value
Writable
false
Enumerable
false
Configurable
false
Common patterns
JavaScript
Number.NaN; // NaN
Object.is(Number.NaN, NaN); // true
Number.NaN === Number.NaN; // false ← never equals itself
Number.isNaN(Number.NaN); // true
0 / 0; // NaN
Infinity - Infinity; // NaN
Math.sqrt(-1); // NaN
Number("abc"); // NaN
function sanitize(x) {
if (Number.isNaN(x)) {
return Number.NaN;
}
return x;
}
Cheat Sheet
⚡ Quick Reference
Goal
Code
Read Not-A-Number
Number.NaN
Same as global?
Object.is(Number.NaN, NaN)
Detect NaN (safe)
Number.isNaN(x)
Never do this
x === Number.NaN (always false)
Indeterminate math
0 / 0 → NaN
Failed conversion
Number("abc") → NaN
Snapshot
🔍 At a Glance
Four facts to remember about Number.NaN.
Kind
static
Property on Number
Value
NaN
Same as global NaN
=== self?
false
Use Number.isNaN
Mutable
no
Read-only constant
Compare
📋 Number.isNaN vs isNaN vs === Number.NaN
Number.isNaN(x)
isNaN(x)
x === Number.NaN
NaN
true
true
false
"foo"
false
true (coerces)
false
undefined
false
true
false
42
false
false
false
Best for?
Real NaN only
Loose “not numeric”
Never use
Hands-On
Examples Gallery
Examples follow MDN Number.NaN patterns. Use View Output or Try It Yourself for each case.
📚 Getting Started
Read the constant and see why strict equality fails.
Example 1 — Read Number.NaN
Confirm it is the same Not-A-Number as global NaN.
The first if is dead code. The second branch catches NaN (and other non-numeric values if you use global isNaN). Prefer Number.isNaN for NaN-only checks.
Example 4 — Common Ways to Get NaN
Invalid math and failed conversions all produce Not-A-Number.
JavaScript
0 / 0; // NaN
Infinity - Infinity; // NaN
Math.sqrt(-1); // NaN
Number("abc"); // NaN
parseFloat("xyz"); // NaN
MDN uses global isNaN so strings like "abc" are treated as non-numeric. Returning Number.NaN keeps the failure signal on the Number API. For NaN-only (no coercion), use Number.isNaN.
Applications
🚀 Common Use Cases
Failed conversion signal — return Number.NaN when parsing fails.
Invalid math marker — detect poisoned results after 0 / 0 style ops.
Input validation — reject bad numeric fields with Number.isNaN.
Sentinel values — some APIs use NaN to mean “unknown number”.
Teaching IEEE-754 — show that NaN ≠ NaN by design.
Pair with isFinite — reject NaN, Infinity, and -Infinity together.
🧠 How Values Become NaN
1
Start with invalid math or text
Divide zeros, subtract infinities, or convert non-numeric strings.
Input
2
No numeric result exists
IEEE-754 has no finite answer for that operation.
Limit
3
Produce NaN
The result becomes Number.NaN / global NaN.
Result
4
✅
Detect with isNaN helpers
Never use === — use Number.isNaN or Object.is.
Important
📝 Notes
This is a static property — use Number.NaN only.
Do not write Number.NaN() — it is not a function.
Number.NaN === Number.NaN is always false.
Object.is(Number.NaN, NaN) is true.
Prefer Number.isNaN() over global isNaN when you mean “is this NaN?”.
typeof NaN is "number" — surprising but correct.
Compatibility
Browser & Runtime Support
Number.NaN is Baseline Widely available and supported in every modern browser and Node.js.
✓ Baseline · Widely available
Number.NaN
Safe for production everywhere. Same Not-A-Number value as global NaN, grouped under Number.
100%Universal support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
Number.NaNExcellent
Bottom line: Use Number.NaN to name Not-A-Number. Detect with Number.isNaN — never with ===. Remember NaN never equals itself.
Wrap Up
Conclusion
Number.NaN is the static constant for Not-A-Number — the value you get from invalid math and failed conversions, identical in value to global NaN.
Pair with Number.isFinite for full non-finite checks
❌ Don’t
Write (5).NaN or call it as a function
Compare with x === Number.NaN (always false)
Assume typeof NaN is something other than "number"
Ignore that isNaN("foo") coerces and returns true
Forget NaN “poisons” further arithmetic
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Number.NaN
Static name for IEEE-754 Not-A-Number.
5
Core concepts
🔢01
Kind
static
API
NaN02
Value
NaN
Constant
❌03
===
never
Trap
✓04
Check
isNaN
Validate
⚡05
Mutable
no
Readonly
❓ Frequently Asked Questions
Number.NaN is the Not-A-Number value on Number. It is the same IEEE-754 NaN as the global NaN. Example 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.
Did you know?
NaN is the only JavaScript value where x !== x is true. That is why some older code used x !== x as a NaN check — today, prefer Number.isNaN(x).