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 xx = 2 ** 53 - 1;

console.log(Number.isSafeInteger(xx));

console.log(Number.isSafeInteger(xx + 1) === false);
console.log(Number.isSafeInteger(3.0));

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

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

console.log(Number.isSafeInteger([]) === false);
BUY
ΣJS
JavaScript in Depth

JS Obj Reference

Number

prototype