ES6 - Number.isInteger()


Advertisements

The Number.isInteger() method determines whether the passed value is an integer.

Syntax

var res = Number.isInteger(value);

Parameter Details

Value to be tested for for being an integer.

Return Value

Returns a Boolean value, true or false.

Example

console.log(Number.isInteger(0)); // true
console.log(Number.isInteger(1)); // true
console.log(Number.isInteger(-100000)); // true
console.log(Number.isInteger(0.1)); // false
console.log(Number.isInteger(Infinity)); // false
console.log(Number.isInteger("10")); // false
console.log(Number.isInteger(true)); // false
console.log(Number.isInteger(false)); // false

Output

true
Advertisements