JavaScript Number.MAX_SAFE_INTEGER Property
Number.MAX_SAFE_INTEGER is the largest integer JavaScript numbers can store exactly: 9007199254740991.
Description
The Number.MAX_SAFE_INTEGER static property is the largest safe integer, 253 - 1. Above it, the Number type can't represent every integer, so arithmetic quietly becomes inaccurate. IDs and counters that may exceed it, such as some database IDs, should be handled as strings or BigInt. Number.MIN_SAFE_INTEGER is its negative.
The limit comes from the 53 bits that floating point numbers use to store their digits. Number.isSafeInteger() checks whether a value is within it. Note that calculations can still stay accurate above the limit for some values, such as powers of two, but you can't rely on it.
A common place to meet this limit is JSON from servers written in other languages, where 64-bit integer IDs lose precision when parsed by JSON.parse(). Ask for them as strings, or parse them with a reviver into BigInts.
Syntax
Number.MAX_SAFE_INTEGERValue
9007199254740991 (253 - 1).
Example
Browser Support
The following information will show you the current browser support for the Number.MAX_SAFE_INTEGER property. Hover over a browser icon to see the version that first introduced support for this property.
Desktop





Tablets & Mobile





