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: Format Number
  2. JS: String to Number
  3. JS: Number Object
  4. JS: Number Constructor
  5. JS: Number.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS Basics
  4. JS in Depth
  5. JS Reference
  6. DOM
  7. SVG
  8. JS Misc