Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript isFinite() Function

JavaScript isFinite() Function

Function Reference JavaScript Global Functions


Definition and Usage

The isFinite() function is used to check whether its argument is infinite, or more precisely, whether it is a finite number.

Tip: If the argument is NaN, positive infinity, or negative infinity, it returns false; otherwise it returns true.

Syntax

isFinite(value)

Parameters Description
value Required. The number to be tested.

Browser support

function
isFinite() Yes Yes Yes Yes Yes

Example

Example

Using isFinite() to test for infinity:

document

.

write

(

isFinite

(

123

)

"


"

)

;

document

.

write

(

isFinite

(

1.23

)

"


"

)

;

document

.

write

(

isFinite

(

5

2

)

"


"

)

;

document

.

write

(

isFinite

(

0

)

"


"

)

;

document

.

write

(

isFinite

(

"

Hello

"

)

"


"

)

;

document

.

write

(

isFinite

(

"

2005/12/12

"

)

"


"

)

;

The example above produces the following output:

true

true

true

true

false

false

Try it »

More examples:

Example

isFinite

(

Infinity

)

;

//

false

isFinite

(

NaN

)

;

//

false

isFinite

(

Infinity

)

;

//

false

isFinite

(

0

)

;

//

true

isFinite

(

2

e64

)

;

//

true, while in the stricter Number.isFinite(null) it would yield false

isFinite

(

"

0

"

)

;

//

true, while in the stricter Number.isFinite('0') it would yield false


Function Reference JavaScript Global Functions