String.prototype.charCodeAt

Returns a non-negative 16-bit integer representing the UTF-16 code unit at the specified location.

If the code unit is a surrogate pair, which cannot be represented in 16 bits, returns the just first part of that surrogate pair.

To get the entire code point value, use codePointAt`.

Syntax

charCodeAt(index)

Parameters

Return value

A number in the range from 0 to 65535.

If the index is out of bounds, returns NaN.

See also