![]() |
VOOZH | about |
The String.charCodeAt() method in TypeScript returns the Unicode value of the character at a specified index in a string. It takes an integer index as a parameter and returns the corresponding Unicode value as a number.
string.charCodeAt(index);Parameter: This method accepts a single parameter as mentioned above and described below.
Return Value: This method returns a number indicating the Unicode value of the character at the given index.
The below example illustrates the String charCodeAt() method in TypeScriptJS:
In this example we use charCodeAt(1) to get the Unicode value of the character at index 1 in str, which is e with a value of 101.
Output:
101
In this example we iterates through str, logging each character's Unicode value using charCodeAt().
Output:
Character at 0 is : 74
Character at 1 is : 97
Character at 2 is : 118
Character at 3 is : 97
Notes: