Global isFinite() Function - Javascript Global

Javascript examples for Global:isFinite

Description

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

Parameter Values

Parameter Description
value Required. The value to be tested

Return Value:

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

The following code shows how to Check whether a number is a finite, legal number:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from   w  w  w .j av  a2  s.c  om*/
    var a = isFinite(13) + "<br>";
    var b = isFinite(-1.3) + "<br>";
    var c = isFinite(3-2) + "<br>";
    var d = isFinite(0) + "<br>";
    var e = isFinite("123") + "<br>";
    var f = isFinite("Hello") + "<br>";
    var g = isFinite("2020/12/12");

    var res = a + b + c + d + e + f + g;
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>

Related Tutorials