Example 1 — Finite Number
A normal division result is finite.
Number.isFinite(10 / 5); // true How It Works
10 / 5 is the number 2. It is a number type and finite, so the result is true.
Number.isFinite() is a static method on Number (same API as MDN Number.isFinite). Call Number.isFinite(value) — not on a number instance. It returns true only for finite number values. This tutorial covers syntax, the difference from global isFinite(), five examples, and try-it labs.
Number only
boolean
Finite number
Inf / NaN / other
None
Everywhere
Division by zero, bad math, or missing data can produce Infinity or NaN. Before you format a value or send it to the UI, you often want to know: “Is this a real, finite number?”
Number.isFinite() answers that safely. Unlike the older global isFinite(), it does not convert strings or other types first — so Number.isFinite("25") is false.
Static methods belong to Number itself. Always write Number.isFinite(x). There is no (5).isFinite() on Number.prototype.
This page is part of JavaScript Number Methods. Related checks include Number.isInteger() and Number.isNaN().
isFinite() MethodPass any value to Number.isFinite(value). You get true only when both of these are true:
"number" (not a string, object, or null).Infinity, -Infinity, or NaN.Everything else — including number-looking strings — returns false.
General form of the static method Number.isFinite:
Number.isFinite(value) A boolean:
| Value | Returns |
|---|---|
Finite number (e.g. 25, 0, -1.5) | true |
Infinity / -Infinity | false |
NaN | false |
Non-number (e.g. "25", null) | false |
false.Number.isFinite(10 / 5); // true
Number.isFinite(1 / 0); // false
Number.isFinite(0 / 0); // false
Number.isFinite("25"); // false
Number.isFinite(2e64); // true
isFinite("25"); // true (global — coerces!) | Goal | Code |
|---|---|
| Safe finite check | Number.isFinite(x) |
| Reject Infinity | Number.isFinite(1 / 0) → false |
| Reject NaN | Number.isFinite(0 / 0) → false |
| Reject strings | Number.isFinite("0") → false |
| Parse then check | Number.isFinite(Number(s)) |
| Avoid coercion surprises | Prefer Number.isFinite over global isFinite |
Four facts to remember about Number.isFinite().
staticCall on Number, not instances
booleantrue only for finite numbers
noneUnlike global isFinite()
BaselineES2015+ everywhere modern
Number.isFinite() vs global isFinite()Number.isFinite(x) | isFinite(x) | |
|---|---|---|
| Coerces first? | No | Yes (ToNumber) |
"25" | false | true |
null | false | true (becomes 0) |
Infinity | false | false |
| Best for | Strict type-safe checks | Legacy / coerced input |
Examples follow MDN patterns. Use View Output or Try It Yourself for each case.
Finite numbers vs Infinity and NaN.
A normal division result is finite.
Number.isFinite(10 / 5); // true 10 / 5 is the number 2. It is a number type and finite, so the result is true.
Dividing by zero yields Infinity — not finite.
Number.isFinite(1 / 0); // false 1 / 0 is Infinity. Number.isFinite(Infinity) and Number.isFinite(-Infinity) are both false.
NaN, non-numbers, and large finite values.
0 / 0 is NaN, which is not finite.
Number.isFinite(0 / 0); // false NaN has type "number", but it is not a finite value, so the check fails.
Unlike global isFinite, numeric-looking strings are rejected.
Number.isFinite("25"); // false
// isFinite("25"); // true (global coerces) The argument is a string, so Number.isFinite returns false immediately. Parse first if you want to accept text input: Number.isFinite(Number("25")).
Huge magnitudes can still be finite numbers.
Number.isFinite(2e64); // true 2e64 is a normal finite Number value. Finiteness is not the same as “small” or “safe integer.”
toFixed / toPrecision on finite values.Infinity / NaN that JSON cannot represent well.Number(raw), confirm the result is finite.Number.isFinite() DecidesAny JavaScript value can be passed in.
Must be typeof number — no coercion.
Infinity, -Infinity, and NaN fail.
true only for finite numbers.
Number.isFinite(x) only.null, or objects.Number objects (wrappers) are objects, so Number.isFinite(new Number(1)) is false.isFinite is older and coercing — prefer the Number static method in new code.Number.isFinite(1.5) is true.Number.isFinite() is Baseline Widely available — part of ES2015 and supported in every modern browser and Node.js.
Safe for production everywhere. Prefer it over global isFinite() for type-safe checks.
Bottom line: Use Number.isFinite for new code. Parse strings yourself before checking if text input must be accepted.
Number.isFinite() is the modern, static way to ask whether a value is a real finite number — without the coercion surprises of global isFinite().
Continue with Number.isInteger() for whole-number checks, or return to the Number methods hub.
Number.isFinite(x) on the constructorNumber(s) before checkingisFinite in new codefalse as “do not use this value in math/UI”(5).isFinite() — that is not a Number method"0" pass the checknew Number(1) is an object (returns false)isFinite(null) being trueNumber.isFinite()Static, strict, boolean check for finite numbers.
static
APIboolean
ResultInf / NaN
Filternone
StrictBaseline
SupportJSON cannot represent Infinity or NaN as numbers — JSON.stringify({ x: Infinity }) becomes {"x":null}. Checking with Number.isFinite before stringify helps you catch bad values early.
Return to the hub for instance and static Number tutorials.
8 people found this page helpful