JS: Number.isSafeInteger

By Xah Lee. Date: .

Number.isSafeInteger ( number )

If number is a integer and its absolute value is ≤ 2^53-1, returns true. Else, false.

const n =  Math.pow (2, 53) -1;

console.log( Number.isSafeInteger (n) ); // true

console.log( Number.isSafeInteger (n+1) ); // false
console.log( Number.isSafeInteger ( 3.0 ) ); // true

console.log( Number.isSafeInteger (NaN) ); // false

console.log( Number.isSafeInteger (Infinity) ); // false

console.log( Number.isSafeInteger ([]) ); // false

Reference

ECMAScript® 2016 Language Specification#sec-number.issafeinteger

Number Topic


  1. JS: Number Object
  2. JS: Number Constructor
  3. JS: Number.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth