JavaScript isFinite() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Global function

Definition

isFinite() tells you whether a value is a normal, usable number. It returns true for numbers like 42 or 3.14, and false for NaN, Infinity and -Infinity.

Like isNaN(), it first converts the value to a number. That makes it handy for checking the result of a calculation before you show it, for example after a division.

Remember
isFinite(value);

value   -> anything; it is converted with Number(value) first
returns -> true for a normal number
           false for NaN, Infinity and -Infinity

Number.isFinite() does the same without the conversion.

Syntax

Call isFinite() by name and give it any value.

JavaScript
isFinite(value);
CallWhat it does
isFinite(42)A normal number. Result: true.
isFinite("3.14")The text becomes 3.14. Result: true.
isFinite(10 / 0)Dividing by zero gives Infinity. Result: false.
isFinite("hello")The text becomes NaN. Result: false.

Built into JavaScript (ES1). It is a global function, so you call it by name with no import. Number.isFinite() is a different, stricter function (ES2015). See also: isNaN(), parseFloat() and parseInt().

Library declarations
JavaScript
// Global function (ES1)
isFinite(value)

// returns true or false
// isFinite(x) is the same as Number.isFinite(Number(x))

Parameters

ParameterDescription
valueThe value to test. It can be a number, text, undefined, null, a boolean, an object or an array. It is converted to a number with Number(value) before the test. A BigInt or a Symbol throws a TypeError during that conversion.

Return Value

Return ValueDescription
trueThe value is, or converts to, a normal number: not NaN and not infinite.
falseThe value is, or converts to, NaN, Infinity or -Infinity.

JavaScript Examples

Example 1 — Check Different Values

Pass numbers, text, NaN and infinite results to isFinite().

JavaScript
console.log("42: " + isFinite(42));
console.log("'3.14': " + isFinite("3.14"));
console.log("'hello': " + isFinite("hello"));
console.log("NaN: " + isFinite(NaN));
console.log("Infinity: " + isFinite(Infinity));
console.log("-Infinity: " + isFinite(-Infinity));
console.log("10 / 3: " + isFinite(10 / 3));
console.log("10 / 0: " + isFinite(10 / 0));
console.log("Biggest number: " + isFinite(Number.MAX_VALUE));
Try It Yourself

How It Works

  1. Normal numbers. 42, "3.14" and 10 / 3 are all finite, so the answer is true.
  2. NaN and text. "hello" becomes NaN, and NaN is not finite.
  3. Infinity. JavaScript does not stop on a division by zero. 10 / 0 is Infinity, and isFinite() says false.
  4. Big is still finite. Number.MAX_VALUE is the biggest normal number. Only values past it become Infinity.

Example 2 — Guard a Calculation

Check the result before showing it. A bad input then gives a clear message instead of NaN or Infinity.

JavaScript
function average(total, count) {
  const result = total / count;

  if (!isFinite(result)) {
    return "Cannot calculate";
  }

  return "Average: " + result;
}

console.log(average(90, 3));
console.log(average(90, 0));
console.log(average(0, 0));
console.log(average("abc", 2));
Try It Yourself

How It Works

  1. Calculate first. average() divides the total by the count and stores the result.
  2. Test the result. !isFinite(result) is true when the result is NaN or infinite, and the function returns a message.
  3. Three kinds of failure, one check. 90 / 0 is Infinity, 0 / 0 is NaN, and "abc" / 2 is NaN. All three are caught.

Example 3 — Compare isFinite() and Number.isFinite()

The two functions agree on real numbers but not on other values.

JavaScript
const values = ["25", "", null, true, 25, "abc"];

values.forEach(function (value) {
  const line = JSON.stringify(value) + " -> isFinite: " + isFinite(value) +
    ", Number.isFinite: " + Number.isFinite(value);
  console.log(line);
});
Try It Yourself

How It Works

  1. Global isFinite() converts. The text "25", empty text, null and true become 25, 0, 0 and 1, so it returns true.
  2. Number.isFinite() does not convert. It returns true only when the value is already a number, so only 25 passes.
  3. Text that is not a number. "abc" fails in both functions.
  4. Which to use? Use Number.isFinite() to validate data you expect to be a number. Use isFinite() only when you want the conversion.

Browser & Runtime Support

isFinite() is one of the oldest functions in JavaScript. Every browser and every Node.js version has it. Number.isFinite() arrived later, with ES2015.

✓ ES1 · Works everywhere

isFinite()

Supported in all browsers, including old ones, and in Node.js, Deno and Bun.

ES1 Standard since
Google Chrome All versions · Desktop & Mobile
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Opera All versions
Full support
Samsung Internet All versions · Android
Full support
Android WebView All versions
Full support
Node.js All versions · Server runtime
Supported
Deno All versions · JavaScript runtime
Supported
Bun All versions · JavaScript runtime
Supported
Internet Explorer All versions
Full support
isFinite() Excellent

Bottom line: Safe to use anywhere. The stricter Number.isFinite() is missing only in Internet Explorer.

Frequently Asked Questions

It converts the value to a number and returns true if the result is a normal number. It returns false for NaN, Infinity and -Infinity. For example isFinite(10 / 0) is false and isFinite(10 / 3) is true.
isFinite() converts the value to a number first, so isFinite("25") is true. Number.isFinite() does no conversion and returns true only for real numbers, so Number.isFinite("25") is false. Use Number.isFinite() for strict checks.
isNaN() is true only for NaN. isFinite() is false for NaN and also for Infinity and -Infinity. Use isFinite() when you want to reject every value that is not an ordinary number.
No. 10 / 0 gives Infinity and 0 / 0 gives NaN. Test the result with isFinite() if you want to show a message instead.
Yes, up to Number.MAX_VALUE (about 1.79e308). Calculations that go past that value become Infinity, and isFinite() then returns false.

Next: isNaN()

Learn how to test for NaN, the value that is not equal to itself.

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.

11 people found this page helpful