JavaScript: Number.isSafeInteger

By Xah Lee. Date: . Last updated: .
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
JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

Number

prototype