W3Schools.com

JavaScript isFinite() Function

Function Reference JavaScript Global Functions

Definition and Usage

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

Tip: This function returns false if the value is +infinity, -infinity, or NaN.

Syntax

isFinite(value)

Parameter Description
value Required. The value to be tested


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The isFinite() function is supported in all major browsers.


Example

Example

Check whether a number is a finite, legal number:

<script type="text/javascript">

document.write(isFinite(123)+ "<br />");
document.write(isFinite(-1.23)+ "<br />");
document.write(isFinite(5-2)+ "<br />");
document.write(isFinite(0)+ "<br />");
document.write(isFinite("Hello")+ "<br />");
document.write(isFinite("2005/12/12")+ "<br />");

</script>

The output of the code above will be:

true
true
true
true
false
false

Try it yourself »


Function Reference JavaScript Global Functions
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE