JavaScript Number isSafeInteger() method

All integers which can be represented as an IEEE-754 double-precision number are considered safe integers.

JavaScript Number.isSafeInteger() is used to check whether the given number is a safe integer or not.

Syntax:

Number.isSafeInteger(number)

Parameters
number: It represents the number on which safe integer checks have to be informed.

Returns
It returns true if the specified number is a safe integer otherwise returns false.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
function testThreadSafe() {
var result = "";
result = result + Number.isSafeInteger(453) + ": 453<br>";
result = result + Number.isSafeInteger(-453) + ": -453<br>";
result = result + Number.isSafeInteger(53-21) + ": 53-21<br>";
result = result + Number.isSafeInteger('456') + ": '456'<br>";
result = result + Number.isSafeInteger(false) + ": false<br>";
result = result + Number.isSafeInteger(Infinity) + ": Infinity<br>";
document.writeln(result);
}
testThreadSafe();
</script>
</body>
</html>