Example 1 — Read Number.MAX_VALUE
Print the largest finite Number.
Number.MAX_VALUE;
// 1.7976931348623157e+308 How It Works
This is a fixed IEEE-754 upper bound. Prefer the named constant over typing the literal by hand.
Number.MAX_VALUE is a static data property on Number (same API as MDN Number.MAX_VALUE). It is the largest positive finite Number — about 1.8e+308. Anything larger becomes Infinity. This tutorial covers its value, overflow guards, how it differs from MAX_SAFE_INTEGER, five examples, and try-it labs.
Static property
~1.8e+308
Largest finite
→ Infinity
No
Everywhere
IEEE-754 doubles can only grow so large. Past that ceiling, JavaScript stops storing a real magnitude and uses Infinity instead. Number.MAX_VALUE is that ceiling for positive finite numbers.
You almost never need to hard-code 1.7976931348623157e+308. Prefer the named constant Number.MAX_VALUE when checking overflow or documenting the upper bound of the Number type.
Static properties belong to Number itself. Always write Number.MAX_VALUE. There is no (5).MAX_VALUE, and you do not call it like a function.
This page is part of JavaScript Number Properties. Related topics include Number.EPSILON, Number.isFinite(), and Number.isSafeInteger().
MAX_VALUE PropertyNumber.MAX_VALUE is approximately 1.7976931348623157e+308 (exactly 21024 − 2971 in the IEEE-754 sense).
-Number.MAX_VALUE and Number.MAX_VALUE.MAX_VALUE become Infinity.MAX_SAFE_INTEGER.General form of the static property Number.MAX_VALUE:
Number.MAX_VALUE Approximately 1.7976931348623157e+308.
| Attribute | Value |
|---|---|
| Writable | false |
| Enumerable | false |
| Configurable | false |
Number.MAX_VALUE; // ≈ 1.7976931348623157e+308
Number.MAX_VALUE * 1.1; // Infinity
-Number.MAX_VALUE * 1.1; // -Infinity
function multiply(x, y) {
if (x * y > Number.MAX_VALUE) {
return "Process as Infinity";
}
return x * y;
} | Goal | Code |
|---|---|
| Read the upper bound | Number.MAX_VALUE |
| Most negative finite | -Number.MAX_VALUE |
| Detect overflow | x * y > Number.MAX_VALUE |
| Check finite result | Number.isFinite(result) |
| Exact large integers | Number.MAX_SAFE_INTEGER / BigInt |
| Tiny positive Number | Number.MIN_VALUE (not −MAX_VALUE) |
Four facts to remember about Number.MAX_VALUE.
staticProperty on Number
~1.8e308Largest finite Number
InfinityAbove the ceiling
noRead-only constant
MAX_VALUE vs MAX_SAFE_INTEGER vs InfinityMAX_VALUE | MAX_SAFE_INTEGER | Infinity | |
|---|---|---|---|
| Approx. size | ~1.8e+308 | 9.007e+15 | Not finite |
| Meaning | Largest finite float | Largest exact integer | Overflow / limit |
Number.isFinite | true | true | false |
| All integers exact? | No | Yes (up to that int) | — |
Examples follow MDN Number.MAX_VALUE patterns. Use View Output or Try It Yourself for each case.
Read the constant and watch overflow become Infinity.
Number.MAX_VALUEPrint the largest finite Number.
Number.MAX_VALUE;
// 1.7976931348623157e+308 This is a fixed IEEE-754 upper bound. Prefer the named constant over typing the literal by hand.
InfinityMultiplying past the ceiling loses the real magnitude.
Number.MAX_VALUE * 1.1; // Infinity Once a value is Infinity, further math usually stays infinite. Check with Number.isFinite().
MDN-style guards and how MAX_VALUE relates to safe integers.
Return a message when the product would exceed MAX_VALUE.
function multiply(x, y) {
if (x * y > Number.MAX_VALUE) {
return "Process as Infinity";
}
return x * y;
}
multiply(1.7976931348623157e308, 1);
// 1.7976931348623157e+308
multiply(1.7976931348623157e308, 2);
// "Process as Infinity" MDN’s pattern detects overflow before you treat the product as a normal finite number.
MAX_SAFE_INTEGERHuge and finite is not the same as exactly countable.
Number.MAX_SAFE_INTEGER; // 9007199254740991
Number.MAX_VALUE > Number.MAX_SAFE_INTEGER; // true
Number.isSafeInteger(Number.MAX_VALUE); // false Use isSafeInteger() (or BigInt) when every integer step must stay exact.
The most negative finite Number is -Number.MAX_VALUE.
-Number.MAX_VALUE; // -1.7976931348623157e+308
-Number.MAX_VALUE * 1.1; // -Infinity Do not confuse this with Number.MIN_VALUE, which is the tiniest positive Number near zero.
Infinity.-MAX_VALUE and MAX_VALUE.MAX_VALUEMultiply, exponentiate, or accumulate toward huge magnitudes.
Ask whether the result is still ≤ Number.MAX_VALUE.
Within range → keep the Number. Past it → Infinity.
Return a message, clamp, or switch to BigInt / another strategy.
Number.MAX_VALUE only.Number.MAX_VALUE() — it is not a function.MAX_VALUE become Infinity and lose their magnitude.MAX_VALUE is not the same as MAX_SAFE_INTEGER.Number.MIN_VALUE is the smallest positive Number, not -MAX_VALUE.Number.MAX_VALUE is Baseline Widely available and supported in every modern browser and Node.js.
Safe for production everywhere. Use it as the named upper bound of finite Numbers.
Bottom line: Use Number.MAX_VALUE to reason about overflow. Use MAX_SAFE_INTEGER or BigInt when exact integers matter.
Number.MAX_VALUE is the static constant for the largest positive finite JavaScript Number. Past that point, results become Infinity.
Continue with EPSILON, isFinite(), isSafeInteger(), or the Number properties hub.
Number.MAX_VALUE on the constructorNumber.isFinite() after aggressive math-Number.MAX_VALUE for the negative finite bound(5).MAX_VALUE or Number.MAX_VALUE()MAX_VALUE with MAX_SAFE_INTEGERMIN_VALUE with -MAX_VALUEInfinity results in production mathNumber.MAX_VALUEStatic upper bound for finite JavaScript Numbers.
static
API~1.8e308
ConstantInfinity
Limitsafe int
Caveatno
ReadonlyNumber.MAX_VALUE is about 1.8 × 10308 — far larger than the number of atoms often estimated in the observable universe — yet many integers near that size cannot be represented exactly as a JavaScript Number.
Return to the hub for static Number constants.
8 people found this page helpful