Easy Tutorial
❮ Jsref Exp Prop Search Disabled ❯

JavaScript charCodeAt() Method

JavaScript String Object

Example

Returns the Unicode encoding of the first character in the string (Unicode value of H):

n Output result:


Definition and Usage

The charCodeAt() method returns the Unicode encoding of the character at the specified position. The return value is an integer between 0 and 65535, representing the UTF-16 code unit at the given index.

The position of the first character in the string is 0, the second character is 1, and so on.


Browser Support

The numbers in the table indicate the first browser version that supports the method.

Method
charCodeAt() Yes Yes Yes Yes Yes

Syntax

Parameter Values

Parameter Description
index Required. A number representing a position in the string, i.e., the index of the character in the string.

Return Value

Type Description
Number Returns the Unicode encoding of the character at the specified position.

Technical Details

| JavaScript Version: | 1.2 | | --- | --- |


More Examples

Example

Returns the Unicode encoding of the last character in the string:

n Output result:


JavaScript String Object

❮ Jsref Exp Prop Search Disabled ❯