JavaScript Number.isInteger() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

Number.isInteger(value) returns true only when value is a number and an integer (no fractional part). It is a static method (ES2015) and does not coerce types.

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call Number.isInteger. Start with this line.

JavaScript
Number.isInteger(value)
CallWhat it does
Number.isInteger(value)Primary signature.
Number.isInteger(...)Call with the arguments your case needs.

Built into JavaScript. Call Number.isInteger(...) on the Number constructor — no import required.

Library declarations
JavaScript
Number.isInteger(value)

Parameters

ParameterDescription
valueRequired. Any value to test

Return Value

Return ValueDescription
*true or false

JavaScript Examples

Example 1 — Integers Pass

Zero, negatives, and 5.0 all count as integers.

JavaScript
console.log(Number.isInteger(0));         // true
console.log(Number.isInteger(-100000));   // true
console.log(Number.isInteger(5.0));       // true
console.log(Number.isInteger(10 / 5));    // true
Try It Yourself

How It Works

  1. Zero counts. 0 is a number with no fractional part → true.
  2. Sign is irrelevant. -100000 is still a whole number.
  3. 5.0 is 5. Writing 5.0 does not store a fraction — same value as 5.
  4. Even division. 10 / 5 yields 2, which is an integer.

Example 2 — Floats, Infinity, and NaN Fail

Finite decimals pass isFinite but fail isInteger.

JavaScript
console.log(Number.isInteger(0.1));       // false
console.log(Number.isInteger(11 / 5));    // false — 2.2
console.log(Number.isInteger(Infinity));  // false
console.log(Number.isInteger(NaN));       // false
Try It Yourself

How It Works

  1. Fractional part. 0.1 is finite but not an integer.
  2. Uneven division. 11 / 5 is 2.2 → false.
  3. Infinity rejected. Specials are not integers, even though their type is number.
  4. vs isFinite. Number.isFinite(0.1) is true — different job.

Example 3 — No String Coercion

Text that looks numeric is still a string — parse first if you need it.

JavaScript
console.log(Number.isInteger("10"));           // false
console.log(Number.isInteger(Number("10")));   // true
console.log(Number.isInteger(true));           // false
console.log(Number.isInteger(null));           // false
Try It Yourself

How It Works

  1. Strict type check. "10" is a string → false.
  2. Parse then check. Number("10") yields 10 → true.
  3. Booleans fail. true is not type number (unlike some global coercing APIs).
  4. null fails. No coercion to 0 — stay explicit about types.

Browser & Runtime Support

Number.isInteger() is part of ES2015 and is Baseline Widely available in modern browsers and Node.js.

✓ Baseline · ES2015

Number.isInteger()

Supported in Chrome, Firefox, Safari, Edge, and Node.js for years. Safe for modern apps without a polyfill.

98% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Number.isInteger Excellent

Bottom line: Use Number.isInteger for new code. Fall back to a polyfill only if you must support very old environments.

Frequently Asked Questions

Number.isInteger(value) returns true only when value is a number and an integer (no fractional part). Example: Number.isInteger(0) is true; Number.isInteger(0.1) is false.
Yes. Call it on Number itself: Number.isInteger(x). Do not call it on a number instance like (5).isInteger() — that is not the Number API.
No. Number.isInteger("10") is false because the value is a string. Parse first if you need to accept text: Number.isInteger(Number("10")).
Yes. Number.isInteger(5.0) is true because 5.0 is the same number value as 5 — there is no fractional part stored.
Number.isFinite(1.5) is true (finite but not an integer). Number.isInteger(1.5) is false. Both reject Infinity, NaN, and non-numbers.
It is Baseline Widely available (ES2015) and supported in every modern browser and Node.js.

Next: isNaN()

Learn how to detect NaN without the coercion traps of global isNaN.

isNaN() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful