charCodeAt()

ES3+

Returns the UTF-16 code unit at the specified index.

Syntax

string.charCodeAt(index)

Parameters

index number

The index of the character

Return Value

number

A number representing the UTF-16 code unit

Examples

JavaScript
const str = 'ABC';
console.log(str.charCodeAt(0));
console.log(str.charCodeAt(1));
Output:
// 65 66

Related Methods