Search This Blog

Thursday, 28 July 2016

How to unicode or numeric value of given string using Javascript?

Html page:

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

JavaScript Page:

<script>
function myFunction()
{
    var str = "HELLO WORLD";
    var n = str.charCodeAt(0);
    document.getElementById("demo").innerHTML = n;
}
</script>

Output:

72

No comments:

Post a Comment