Javascript - Global isFinite() Function

The isFinite() function determines whether a number is a finite, legal number.

Description

The isFinite() function determines whether a number is a finite, legal number.

This function returns false if the value is +infinity, -infinity, or NaN (Not-a-Number), otherwise it returns true.

Syntax

isFinite(value)

Parameter Values

Parameter Require Description
value Required. The value to be tested

Return

A Boolean. Returns false if the value is +infinity, -infinity, or NaN, otherwise it returns true.

Example

Check whether a number is a finite, legal number:

Demo

var a = isFinite(124) + "\n";
var b = isFinite(-1.24) + "\n";
var c = isFinite(5 - 2) + "\n";
var d = isFinite(0) + "\n";
var e = isFinite("123") + "\n";
var f = isFinite("dead") + "\n";
var f = isFinite("book2s.com") + "\n";
var g = isFinite("2010/12/12");

var res = a + b + c + d + e + f + g;
console.log(res);//from  w  w  w .j a v  a2s.c  om

Result