Search This Blog

Monday, 1 August 2016

Javascript isInteger() method example program?

Html page:

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

Javascript page:

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

Output:

true: 123
true: -123
true: 5-2


No comments:

Post a Comment