Skip to content

isFinite()

The global isFinite() function converts its argument to a number and returns true when the result is a finite number, or false when it’s NaN, Infinity, or -Infinity. Because of that conversion, a numeric string counts as finite:

Language: JavaScript
> isFinite("42")
true
> isFinite(Infinity)
false
> isFinite("forty-two")
false

isFinite() is an ECMAScript built-in. The static method Number.isFinite() is a separate function that skips the conversion, so Number.isFinite("42") returns false.

Syntax

The isFinite() function takes a single argument:

Language: JavaScript Syntax
isFinite(<value>)
Parameter Description
value The value to test. Any value that isn’t a number is converted to one first, with the same rules as the unary plus operator, +value

The function isn’t a constructor, so calling it with new throws a TypeError.

Return Value

The result is a boolean: false when the converted value is NaN, Infinity, or -Infinity, and true for every other number.

The conversion runs before the check, so it can throw. A bigint or a symbol argument throws a TypeError, because neither converts to a number. An object’s [Symbol.toPrimitive](), .valueOf(), or .toString() method runs during the conversion, and any error it throws propagates.

Examples

An analytics dashboard computes a click-through rate by dividing clicks by views. A page with no views produces Infinity or NaN, and isFinite() catches both before the rate reaches a chart:

Language: JavaScript
> const rate = (clicks, views) => clicks / views;
undefined

> isFinite(rate(30, 1200))
true
> isFinite(rate(30, 0))
false
> isFinite(rate(0, 0))
false

A settings form reads a numeric limit from a text field. A value written in exponent notation can overflow the largest number, and the conversion turns it into Infinity:

Language: JavaScript
> isFinite("1e308")
true
> isFinite("1e309")
false

Common Gotchas

Empty and whitespace-only strings, null, and Booleans all convert to real numbers, so isFinite() reports them as finite. A form check built on isFinite() alone accepts a blank field:

Language: JavaScript
> isFinite("")
true
> isFinite("   ")
true
> isFinite(null)
true
> isFinite(true)
true

A BigInt value can’t be converted to a number, so the call throws instead of returning true:

Language: JavaScript
> isFinite(10n)
Uncaught TypeError: Cannot convert a BigInt value to a number
    at isFinite (<anonymous>)

To test whether a value is a finite number without any conversion, Number.isFinite() returns false for every argument that isn’t a number, including a bigint.

A developer pulls a Math.floor() lever on a counting machine with a coffee sack on its scale, a big dial, a % gauge and a toFixed(2) receipt printer.

Course

JavaScript Numbers for Pythonistas

Port a coffee roastery's batch planner from Python to JavaScript, and learn to divide, round, read numbers from text, and format them with JavaScript's one number type.

basics js py

For additional information on related topics, take a look at the following resources:

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Leodanis Pozo Ramos • Updated Nov. 14, 2026