JavaScript (ES2026) reference · Number Methods and Properties

JavaScript Number.isSafeInteger() Method

Return true if a value is an integer that can be represented exactly, between -(2^53 - 1) and 2^53 - 1.

JavaScript (ES2026) Since ES2015

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

Number.isSafeInteger(value)

Parameters

ParameterDescription
value The value to test.

Return value

true or false.

Examples

The safe rangeTry it yourself
console.log(Number.isSafeInteger(2 ** 53 - 1), Number.isSafeInteger(2 ** 53));

Output

true false
Use BigInt beyond itTry it yourself
console.log(2 ** 53 === 2 ** 53 + 1); // precision is lost
console.log(2n ** 53n === 2n ** 53n + 1n); // BigInt is exact

Output

true
false

Version history

VersionChange
JavaScript ES2015Added

Was this page helpful?