Number.isSafeInteger (Number) (JavaScript)

Returns a Boolean value that indicates whether a number can be safely represented in JavaScript.

Syntax

Number.isSafeInteger(numValue)   

Return Value

true if the number is between Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER, inclusive; otherwise false.

Remarks

A safe integer in JavaScript is one that is an IEEE-754 double precisions number before any rounding has been applied.

Example

// Returns true  
Number.isSafeInteger(-100)  
Number.isSafeInteger(9007199254740991)  

// Returns false  
Number.isSafeInteger(Number.NaN)  
Number.isSafeInteger(Infinity)  
Number.isSafeInteger("100")  
Number.isSafeInteger(9007199254740992);  

Requirements

Supported in Microsoft Edge (Edge browser). Also supported in Store apps (Microsoft Edge on Windows 10). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.1.

Applies To: Number Object