Number isSafeInteger() method

Find all information about the JavaScript isSafeInteger() method of the Number object

A number may satisfyNumber.isInteger()but notNumber.isSafeInteger()If it is out of the safe integer range, I have explained it above.

So, it's over2^53And below-2^53Not safe:

Number.isSafeInteger(Math.pow(2, 53)) // false
Number.isSafeInteger(Math.pow(2, 53) - 1) // true
Number.isSafeInteger(Math.pow(2, 53) + 1) // false
Number.isSafeInteger(-Math.pow(2, 53)) // false
Number.isSafeInteger(-Math.pow(2, 53) - 1) // false
Number.isSafeInteger(-Math.pow(2, 53) + 1) // true

Download mine for freeJavaScript beginner's manual


More js tutorials: