JavaScript Number.isInteger()

The syntax of the isInteger() method is:

Number.isInteger(value)

The isInteger() method is called using the Number class name.


Number.isInteger() Parameters

The isInteger() method takes in:

  • value - The value to be tested for being an integer.

Return value from Number.isInteger()

  • Returns a Boolean representing whether the given value is an integer.

Note: The isInteger() method returns false for NaN and Infinity.


Example: Using Number isInteger()

console.log(Number.isInteger(453)); // true
console.log(Number.isInteger(-44)); // true
console.log(Number.isInteger(5.0)); // true

console.log(Number.isInteger(456.129)); // false
console.log(Number.isInteger(Math.PI)); // false

console.log(Number.isInteger(NaN)); // 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
console.log(Number.isInteger([1])); // false

Output

true
true
true
false
false
false
false
false
false
false
false
Did you find this article helpful?

Your builder path starts here. Builders don't just know how to code, they create solutions that matter.

Escape tutorial hell and ship real projects.

Try Programiz PRO
  • Real-World Projects
  • On-Demand Learning
  • AI Mentor
  • Builder Community