JavaScript Number MAX_SAFE_INTEGER Property
Last Updated : 15 May, 2023
Improve
The JavaScript Number.MAX_SAFE_INTEGER is a constant number that represents the maximum safe integer. This constant has a value of (253 - 1). Here safe refers to the ability to represent integers and to compare them.
Syntax:
Number.MAX_SAFE_INTEGER
Return Value: A constant number.
Example 1: Below example illustrates the usage of Number.MAX_SAFE_INTEGER
const a = Number.MAX_SAFE_INTEGER + 1;
const b = Number.MAX_SAFE_INTEGER + 2;
console.log(Number.MAX_SAFE_INTEGER);
console.log(a);
console.log(a === b);
Output:
9007199254740991 9007199254740992 true
Example 2: Below example illustrates the usage of the constants Number.MAX_SAFE_INTEGER using Math.pow() function.
const a = Number.MAX_SAFE_INTEGER;
const b = -(Math.pow(2, 53) - 1);
console.log(a);
console.log(b);
console.log(a === b);
Output:
9007199254740991 -9007199254740991 false
Supported Browsers:
- Chrome 34 and above
- Internet Explorer (Not Supported)
- Firefox 31 and above
- Edge 12 and above
- Safari 9 and above
- Opera 21 and above
We have a complete list of JavaScript Number constructor, properties, and methods list, to know more about the numbers please go through that article.