English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
charCodeAt()The method returns a number between 0 and65535The integer between them, which represents the UTF at the given index-16Code unit.
The index of the first character is 0, the index of the second character is1, and so on.
The index of the last character in the string isString .length-1.
string.charCodeAt(index)
var str = 'www.oldtoolbag.com'; str.charCodeAt(1);Test and See‹/›
All browsers fully support the charCodeAt() method:
Method | |||||
charCodeAt() | Is | Is | Is | Is | Is |
Parameter | Description |
---|---|
index | An integer representing the index of the character to return |
Return Value: | A number representing the UTF of the character at the given index-16Code Unit Value; NaN if the index is out of range |
---|---|
JavaScript Version: | ECMAScript 1 |
Returns the UTF of the last character in the string-16Code Unit:
var str = 'oldtoolbag.com'; str.charCodeAt(str.length-1);Test and See‹/›