How to use charCodeAt in JavaScript

In this article we will discuss about How to use charCodeAt() Method in JavaScript.
  • 2600

The charCodeAt() Method is used to return the Unicode value of the character at the particular given index. The Syntax of this method is as follows:

string.charCodeAt(index);

In the above syntax of charCodeAt() method the parameter index indicates an integer value at which index of the particular character in the string we will get the unicode value.

JavaScript Code:

<html>

<head>

    <title>JavaScript String charCodeAt() Method</title>

</head>

<body>

    <script type="text/javascript">

        var st = new String("God is Great");

        document.write("st.charCodeAt(0) is:" + st.charCodeAt(0));

        document.write("<br />st.charCodeAt(1) is:" + st.charCodeAt(1));

        document.write("<br />st.charCodeAt(2) is:" + st.charCodeAt(2));

        document.write("<br />st.charCodeAt(3) is:" + st.charCodeAt(3));

        document.write("<br />st.charCodeAt(4) is:" + st.charCodeAt(4));

        document.write("<br />st.charCodeAt(5) is:" + st.charCodeAt(5));

    </script>

</body>

</html>

Output:
 myoutput1.jpg

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.