JavaScript Number.isSafeInteger() Method
The Number.isSafeInteger() static method checks whether a value is an integer small enough to be stored exactly.
Description
The Number.isSafeInteger() static method returns true if the value is an integer between -(253 - 1) and 253 - 1. Within that range, every integer is stored exactly; beyond it, adjacent integers can't be told apart. Use BigInt for larger values.
A safe integer is one that can be represented exactly and compared correctly. Integers outside the safe range may round to a neighbouring value, so a large ID received as a number could silently point to the wrong record. That's why many APIs send large IDs as strings.
The bounds are available as Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER. Values that aren't numbers, or aren't integers, return false. Like other static members of Number, it is called on the Number constructor itself, not on individual number values.
Syntax
Number.isSafeInteger(value)Parameters
- valueThe value to check.
Return Value
true if the value is an integer that can be represented exactly, otherwise false.
Example
Browser Support
The following information will show you the current browser support for the Number.isSafeInteger() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





