Example 1 — Safe Integers Pass
Everyday integers and the max/min safe limits all pass.
console.log(Number.isSafeInteger(3)); // true
console.log(Number.isSafeInteger(-100)); // true
console.log(Number.isSafeInteger(2 ** 53 - 1)); // true
console.log(Number.isSafeInteger(-(2 ** 53 - 1))); // true How It Works
- Small integers.
3and-100are whole numbers well inside the safe range. - Max boundary.
2 ** 53 - 1equalsNumber.MAX_SAFE_INTEGER→ still safe. - Min boundary. The negative twin
-(2 ** 53 - 1)isMIN_SAFE_INTEGER. - Use case. Good guard before IDs, counters, or index math that must stay exact.

