Search This Blog

Monday, 1 August 2016

How to use isFinite() funtion in javascript?

Html page:

<button onclick="myFunction()">Try it</button>
<p id="P5"></p>

Javascript page:

<script>
    function myFunction() {
        var res = "";
        res = res + Number.isFinite(123) + ": 123<br>";
        res = res + Number.isFinite(-1.23) + ": -1.23<br>";
        res = res + Number.isFinite(5 - 2) + ": 5-2<br>";
        document.getElementById("demo").innerHTML = res;
    }
</script>

Output:
true: 123
true: -1.23
true: 5-2

No comments:

Post a Comment