Open this example in the interactive library
Source code
console.log(
Number.isSafeInteger(2 ** 53 - 1),
Number.isSafeInteger(2 ** 53),
);
Sample output
true false

Check whether an integer is safe to represent in JavaScript.
Open this example in the interactive library
console.log(
Number.isSafeInteger(2 ** 53 - 1),
Number.isSafeInteger(2 ** 53),
);
true false