Search This Blog

Friday, 29 July 2016

How to return the value of the string object in javascript?

Html page:

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

Javascript page:

<script>
    function myFunction() {
        var str = "Hello World!";
        var res = str.toString();
        document.getElementById("demo").innerHTML = res;
    }
</script>

Output:

Hello World!

No comments:

Post a Comment