JavaScript Number isInteger() Method

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Static method

What You’ll Learn

Number.isInteger() is a static method on Number (same API as MDN Number.isInteger). Call Number.isInteger(value) — not on a number instance. It returns true only for integer number values. This tutorial covers syntax, floats vs integers, precision quirks, five examples, and try-it labs.

01

Call on

Number only

02

Returns

boolean

03

True when

Integer number

04

False for

Floats / Inf / NaN

05

Coercion

None

06

Baseline

Everywhere

Introduction

Counts, indexes, and page sizes are usually whole numbers. Number.isInteger() tells you whether a value is an integer — a number with no fractional part.

Like other static Number checks, it does not coerce strings: Number.isInteger("10") is false. Parse first when the input is text.

💡
Static Method

Static methods belong to Number itself. Always write Number.isInteger(x). There is no (5).isInteger() on Number.prototype.

This page is part of JavaScript Number Methods. Related static checks include Number.isFinite() and Number.isNaN().

Understanding the isInteger() Method

Pass any value to Number.isInteger(value). You get true only when both of these are true:

  • The type is "number".
  • The number is an integer (including negatives and 0).

Infinity, -Infinity, NaN, floats like 0.1, and non-numbers all return false. Values written with .0 (such as 5.0) still count as integers.

📝 Syntax

General form of the static method Number.isInteger:

JavaScript
Number.isInteger(value)

Parameters

  • value (any) — the value to test for being an integer.

Return value

A boolean:

ValueReturns
Integer (e.g. 0, 1, -100000, 5.0)true
Non-integer number (e.g. 0.1, Math.PI)false
Infinity / NaNfalse
Non-number (e.g. "10", true)false

Exceptions

  • None for normal calls — invalid types simply return false.

Common patterns

JavaScript
Number.isInteger(0);          // true
Number.isInteger(-100000);    // true
Number.isInteger(0.1);        // false
Number.isInteger("10");       // false
Number.isInteger(5.0);        // true
Number.isInteger(10 / 5);     // true

⚡ Quick Reference

GoalCode
Integer checkNumber.isInteger(x)
Accept text inputNumber.isInteger(Number(s))
Reject floatsNumber.isInteger(0.1)false
Allow 5.0Number.isInteger(5.0)true
Finite but not integer?Number.isFinite(x) && !Number.isInteger(x)
Division fits evenlyNumber.isInteger(y / x)

🔍 At a Glance

Four facts to remember about Number.isInteger().

Kind
static

Call on Number, not instances

Returns
boolean

true only for integer numbers

Coercion
none

Strings and objects fail

Support
Baseline

ES2015+ everywhere modern

📋 Number.isInteger() vs Number.isFinite()

Number.isInteger(x)Number.isFinite(x)
1truetrue
1.5falsetrue
Infinityfalsefalse
"10"falsefalse
Best forWhole-number validationAny finite numeric value

Examples Gallery

Examples follow MDN patterns. Use View Output or Try It Yourself for each case.

📚 Getting Started

Positive, zero, and negative integers.

Example 1 — Zero Is an Integer

0 has no fractional part.

JavaScript
Number.isInteger(0);  // true
Try It Yourself

How It Works

0 is a number and an integer, so the result is true. The same holds for 1, 2, and so on.

Example 2 — Negative Integers

Negative whole numbers count as integers too.

JavaScript
Number.isInteger(-100000);  // true
Try It Yourself

How It Works

The sign does not matter — only whether a fractional part exists.

📈 Practical Patterns

Floats, non-numbers, and even division checks.

Example 3 — Non-Integer Float

Any stored fractional part fails the check.

JavaScript
Number.isInteger(0.1);  // false
Try It Yourself

How It Works

0.1 is finite but not an integer. Number.isInteger(Math.PI) is also false.

Example 4 — No String Coercion

Numeric-looking strings are rejected.

JavaScript
Number.isInteger("10");  // false
Try It Yourself

How It Works

The argument is a string, so the result is false. Use Number.isInteger(Number("10")) when text input should count.

Example 5 — Even Division Fits

An MDN-style check: does y divide evenly by x?

JavaScript
Number.isInteger(10 / 5);  // true
Try It Yourself

How It Works

10 / 5 is 2, an integer. Try Number.isInteger(11 / 5) — that is false because the quotient is 2.2.

🚀 Common Use Cases

  • Indexes & counts — ensure page size, quantity, or array index is whole.
  • Form validation — after parsing input, confirm an integer.
  • Even divisionNumber.isInteger(y / x) for “fits evenly” checks.
  • API contracts — reject fractional IDs or counts before saving.
  • Game / grid logic — tile coordinates that must be integers.
  • Pair with isFinite — first ensure finite, then optionally require integer.

🧠 How Number.isInteger() Decides

1

Receive value

Any JavaScript value can be passed in.

Input
2

Check type

Must be typeof number — no coercion.

Type
3

Check integer

Reject floats, Infinity, and NaN.

Filter
4

Return boolean

true only for integer numbers.

📝 Notes

  • This is a static method — use Number.isInteger(x) only.
  • Does not coerce strings, booleans, arrays, or objects.
  • Number.isInteger(5.0) is true5.0 is the same value as 5.
  • Floating-point limits can surprise you near huge magnitudes (see MDN’s precision notes).
  • Number.isInteger(5.000000000000001) is false, but an even tinier difference may round to 5 and return true.
  • Integer is stricter than finite — use Number.isFinite() when decimals are allowed.

Browser & Runtime Support

Number.isInteger() is Baseline Widely available — part of ES2015 and supported in every modern browser and Node.js.

Baseline · Widely available

Number.isInteger()

Safe for production everywhere. Prefer it for whole-number validation without coercion.

100% Universal 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. Parse strings yourself before checking if text input must be accepted.

Conclusion

Number.isInteger() is the modern, static way to ask whether a value is a whole number — without coercing strings or treating floats as integers.

Continue with Number.isNaN() for NaN detection, Number.isFinite() for any finite value, or return to the Number methods hub.

💡 Best Practices

✅ Do

  • Call Number.isInteger(x) on the constructor
  • Parse user text with Number(s) before checking
  • Use it for counts, indexes, and even-division checks
  • Pair with Number.isFinite when you also need float support
  • Remember 5.0 is still an integer

❌ Don’t

  • Write (5).isInteger() — that is not a Number method
  • Assume strings like "10" pass the check
  • Confuse integer with safe integer (see Number.isSafeInteger)
  • Ignore precision quirks for huge floating values
  • Use it when fractional amounts (money, ratios) are valid

Key Takeaways

Knowledge Unlocked

Five things to remember about Number.isInteger()

Static, strict, boolean check for whole numbers.

5
Core concepts
02

Returns

boolean

Result
. 03

Rejects

floats

Filter
Aa 04

Coercion

none

Strict
05

Safe

Baseline

Support

❓ 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.
Did you know?

Some literals look fractional but encode as integers because of floating-point limits. MDN notes Number.isInteger(5.0000000000000001) can be true because that tiny difference cannot be represented separately from 5.

More Number Methods

Return to the hub for instance and static Number tutorials.

Number methods hub →

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.

8 people found this page helpful