.isInteger()
Published Oct 12, 2021Updated Oct 13, 2021
Contribute to Docs
The Number.isInteger()
method is a part of the Number
class in JavaScript.
It accepts a single argument, value
, and returns true
if the passed argument is an integer, and returns false
otherwise.
Syntax
Number.isInteger(value);
value
(required): The value to check.
Examples
To verify if a value is an integer or not:
const x = 13 / 5;// x = 2.6console.log(Number.isInteger(x));// Output: false
const y = 10 / 5;// y = 2console.log(Number.isInteger(y));// Output: true
The above example passes an integer and a decimal value into Number.isInteger()
method, to verify if the value is an integer or not. Then, the result is printed.
Codebyte Example
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn JavaScript on Codecademy
- Career path
Front-End Engineer
Front-end engineers work closely with designers to make websites beautiful, functional, and fast.Includes 34 CoursesWith Professional CertificationBeginner Friendly115 hours - Free course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner Friendly15 hours