JavaScript Number.MIN_SAFE_INTEGER

The JavaScript Number.MIN_SAFE_INTEGER constant represents the minimum safe integer in JavaScript.

The MIN_SAFE_INTEGER constant has a value of -(253 - 1) or -9007199254740991.

It is a non-writable, non-enumerable, and non-configurable property.

"Safe" refers to the ability of JavaScript to represent integers exactly and to correctly compare them.

The syntax to access the MIN_SAFE_INTEGER constant is:

Number.MIN_SAFE_INTEGER

MIN_SAFE_INTEGER is accessed using the Number class name.


Example: Value of Number.MIN_SAFE_INTEGER

value = Number.MIN_SAFE_INTEGER;
console.log(value); // -9007199254740991

value_minus_1 = value - 1;
value_minus_2 = value - 2;
// JS Number cannot exactly represent integers smaller than 'value'
// and correctly compare them
console.log(value_minus_1 == value_minus_2); // true

Output

-9007199254740991
true

Note: If you have to use integers greater than MAX_SAFE_INTEGER, consider using BigInt.


Recommended Readings:

Did you find this article helpful?