Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JS Puzzles · Const

Number.MAX_SAFE_INTEGER

Number.MAX_SAFE_INTEGER is the Number static property equal to 9007199254740991 (2^53 − 1). It is the greatest integer JavaScript can represent exactly and compare reliably as a Number.

How it works

Number.MAX_SAFE_INTEGER is a static Number property whose value is 9007199254740991, equal to 2^53 − 1. It marks the greatest integer that JavaScript can represent exactly and compare reliably as a Number; calculations beyond it can lose integer precision.

Syntax

Number.MAX_SAFE_INTEGER

Returns

9007199254740991

Key points

  • It is a static data property on Number that identifies JavaScript's upper safe-integer boundary.
  • Its decimal value is 9,007,199,254,740,991.
  • The safe integer interval is symmetric, extending from the corresponding negative limit through this positive limit.
  • Safety means exact representation and correct integer comparisons, not merely that the value is finite.
  • MAX_SAFE_INTEGER is not JavaScript's largest possible numeric magnitude; Number.MAX_VALUE is larger.
  • Operations above the boundary are permitted, although they no longer guarantee integer-level precision.

Common mistakes

  • Different mathematical integers above the boundary can compare equal after rounding to the same Number value.
  • Access it on Number, not through an individual numeric value.

Example: Precision at the safe-integer boundary

const upper = Number.MAX_SAFE_INTEGER;
const next = upper + 1;
const afterNext = upper + 2;

console.log(upper); // 9007199254740991
console.log(next === afterNext); // true

The two different additions produce the same Number value because integers beyond the safe limit cannot always be distinguished precisely.

When to use it

Check safe integer boundaries

Validate identifiers, counters, timestamps, or other integer inputs before storing them as Number values.

Select an integer representation

Choose between Number and BigInt when an integer may exceed the exact-precision range.

Diagnose precision loss

Explain surprising equality or arithmetic results at very large integer magnitudes.

Interview questions

QWhat does Number.MAX_SAFE_INTEGER represent?

Number.MAX_SAFE_INTEGER is 9007199254740991, or 2^53 − 1. It is the largest integer that a JavaScript Number can represent exactly and compare correctly.

Follow-up: What can happen above this value? Different integers may round to one Number value, so equality and integer arithmetic can become unreliable; use BigInt for larger integers.

QWhy is the safe-integer limit 2^53 − 1?

JavaScript Numbers use double-precision floating point, whose mantissa provides 53 bits of integer precision. That makes 2^53 − 1 the largest safely distinguishable integer.

Follow-up: Why does the limit apply to integers rather than all numeric values? Floating-point Numbers can represent much larger magnitudes, but not every integer in those magnitudes exactly.

QShould all arithmetic above Number.MAX_SAFE_INTEGER be avoided?

The property itself is a Number value, so arithmetic beyond it can still produce meaningful approximate results, but integer-level precision is not guaranteed. For exact large-integer calculations, BigInt is the appropriate alternative.

Follow-up: Can Number.MAX_VALUE replace it? No: MAX_VALUE is the largest representable Number magnitude, whereas MAX_SAFE_INTEGER concerns exact integer precision.

  • Number.MIN_SAFE_INTEGER
  • Number.isSafeInteger()
  • Number.MAX_VALUE
  • Number.EPSILON
  • BigInt

Source: Number.MAX_SAFE_INTEGER - JavaScript - MDN Web Docs. Checked 2026-10-15.