The usage of the charCodeAt () method in javasacripat, javacharcodeat
This method returns a number indicating the Unicode value of the character at the given index.
Unicode code points range: 0 to 1114111. The first 128 Unicode vertices are directly matched with the ASCII character encoding. CharCodeAt () always returns a value smaller than 65,536.
Syntax
string.charCodeAt(index);
The following is the detailed information about the parameters:
- Index: the integer between 0 and 1 is smaller than the length of the string. If not specified, the default value is 0.
Return Value:
Returns a number indicating the Unicode value of the character at the given index. If the given index is not the length between 0 and 1, NaN is returned.
Example:
This produces the following results:
str.charCodeAt(0) is:84str.charCodeAt(1) is:104str.charCodeAt(2) is:105str.charCodeAt(3) is:115str.charCodeAt(4) is:32str.charCodeAt(5) is:105