Number

Number.isInteger

Determines whether the passed value is an integer

Syntax

JavaScript
Number.isInteger(value)

Parameters

ParameterTypeDescription
valueanyThe value to be tested

Return Value

true if the value is an integer, false otherwise

Examples

Basic Usage
console.log(Number.isInteger(42)); // true
console.log(Number.isInteger(42.0)); // true
console.log(Number.isInteger(42.5)); // false
Practical Example
console.log(Number.isInteger('42')); // false
console.log(Number.isInteger(Infinity)); // false
console.log(Number.isInteger(NaN)); // false
Advanced Usage
function validateAge(age: unknown): age is number {
  return typeof age === 'number' && Number.isInteger(age) && age > 0;
}

Understanding Number.isInteger

The Number.isInteger method in JavaScript determines whether the passed value is an integer. It belongs to the Number object and is one of the most widely used methods for working with number values in modern JavaScript and TypeScript applications.

The method signature is Number.isInteger(value). It accepts 1 parameter: value. When called, it returns true if the value is an integer, false otherwise. Understanding when and how to use isInteger() helps you write more expressive, readable code.

Common use cases for Number.isInteger include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like number-issafeinteger, number-isfinite, number-isnan, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Number.isInteger is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Number Methods

Other methods in the Number object

Related Tools

More Number Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.