EN
JavaScript - get max supported integer value
3 points
In this article, we would like to show you how to get supported max integer value in JavaScript.
Quick solution:
JavaScript supports 53 bits integer numbers when we work on
number
type.
9007199254740991
(in dec)
11111111111111111111111111111111111111111111111111111
(in bin)
1FFFFFFFFFFFFF
(in hex)
xxxxxxxxxx
1
const maxValue = Number.MAX_SAFE_INTEGER; // 9007199254740991
In this example, we print in the console the Number.MAX_SAFE_INTEGER
constant that represents the maximum safe integer in JavaScript.
xxxxxxxxxx
1
console.log(Number.MAX_SAFE_INTEGER); // 9007199254740991
Output:
xxxxxxxxxx
1
9007199254740991