isFinite() global function JS Home  <<  JS Reference  <<  isFinite()

Global function finite test.

Description

Evaluates the passed argument to see if it is finite.

Syntax

Signature Description
isFinite(number)Evaluates the passed argument to see if it is finite.

Parameters

Parameter Description
numberThe numerical value you want to evalute:

  • +/- infinity and NaN evaluate to false.
  • All other numerical values evaluate to true.

Examples

Below are some examples of using the isFinite() function.


// The isFinite method returns true for all values except +/- infinity and NaN.
var isFiniteValues = new Array(5);
isFiniteValues[0] = isFinite(Number.NEGATIVE_INFINITY);
isFiniteValues[1] = isFinite(Number.POSITIVE_INFINITY);
isFiniteValues[2] = isFinite(NaN);
isFiniteValues[3] = isFinite(-123456789);
isFiniteValues[4] = isFinite(123.456);
alert(isFiniteValues);  

Press the button below to action the above code:

Related Tutorials

JavaScript Advanced Tutorials - Lesson 3 - Number