- Added in ES2020 (ES11)
- Represents whole numbers larger than 253 - 1
- Numbers larger than previous
Number.MAX_SAFE_INTEGER
- requires the use of
n
character to be appended at the end
-
BigInt
is not strictly equal to Number
, but is loosely equal:
0n === 0 // strict check (===)
// => false
0n == 0 // loose equality (==)
// => true
const previousMaxSafe = BigInt(Number.MAX_SAFE_INTEGER)
// => 9007199254740991n
const theFuture = previousMaxSafe + 2n
// => 9007199254740993n
// previously this would cause an error