Search This Blog

Saturday, 30 July 2016

How to show the primitive value of the string using javascript?

Html page:

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

Javascript page:

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

Output:

Hello World!

No comments:

Post a Comment