Javascript examples for Global:isFinite
The isFinite() function returns false if the value is +infinity, -infinity, or NaN (Not-a-Number), otherwise it returns true.
Parameter | Description |
---|---|
value | Required. The value to be tested |
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:
<!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>