Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JavaScript · Function

isFinite

Number.isFinite() checks whether a value is a finite JavaScript number. It returns false for non-numbers, NaN, and positive or negative infinity.

How it works

Call Number.isFinite(value) to test whether value is both a number and finite. Unlike the global isFinite() function, it does not convert non-number inputs before testing, so non-numbers return false.

Syntax

Number.isFinite(value)

Parameters

NameTypeDescription
valueanyThe value to be tested for finiteness.

Returns

A Boolean: true for a finite number and false otherwise.

Key points

  • It is a static method on Number, called as Number.isFinite(value) rather than as a method on an individual number.
  • A successful result requires both numeric type and finiteness; NaN and either sign of infinity fail.
  • Its complete call signature takes one argument named value.
  • The argument can be any value; the method determines whether that value qualifies as a finite number.
  • The return type is Boolean, with true reserved for finite numbers.

Common mistakes

  • Do not substitute the global isFinite() when you need strict numeric validation: that function coerces its argument first.
  • Numeric-looking strings and values such as null are rejected rather than converted.

Example: Filtering finite numeric values

const values = [42, "42", Infinity, NaN, null];
const finiteNumbers = values.filter(Number.isFinite);

console.log(finiteNumbers); // [42]

Only the numeric value 42 passes; strings and other non-finite or non-number values return false.

When to use it

Strict numeric validation

Validate numeric input before arithmetic or calculations.

Filtering datasets

Keep only finite numeric elements when processing mixed data.

Guarding calculations

Reject sentinel values such as NaN and infinities in computation pipelines.

Interview questions

QWhat does Number.isFinite() test?

Number.isFinite(value) returns true only when value has the number type and is not NaN, positive Infinity, or negative Infinity. It returns false for every other value.

Follow-up: How does it differ from global isFinite()? The global function converts non-number arguments first, while Number.isFinite() does not.

QWhat are representative inputs and outputs?

The method accepts one value to test and returns a Boolean. Finite numeric values such as 0 and 2e64 produce true; NaN and either infinity produce false.

Follow-up: What happens for a string such as "0"? Number.isFinite("0") is false because the argument is not a number.

QWhen is Number.isFinite() preferable to global isFinite()?

Use it when input must already be a JavaScript number and must also be usable as a finite numeric value. It combines type strictness with rejection of NaN and both infinities.

Follow-up: Would it validate an integer? No; finite fractional values also pass, so use an integer-specific check when integerness is required.

  • Number.isInteger()
  • Number.isNaN()
  • Number.isSafeInteger()
  • isFinite()

Source: Number.isFinite() - JavaScript - MDN Web Docs. Checked 2026-10-15.