JavaScript String.prototype.codePointAt() Method
The codePointAt() method returns the full Unicode code point of the character at a given position, including emoji and other characters beyond the basic range.
Description
The codePointAt() method returns the Unicode code point starting at the given index. Unlike charCodeAt(), it correctly combines surrogate pairs, so it returns the real value for emoji and other characters above U+FFFF. Its counterpart for creating characters is String.fromCodePoint().
The index is still counted in UTF-16 code units, not characters, so when walking through a string by index you need to skip the second half of each surrogate pair. Looping with for...of avoids that, because it yields one whole code point at a time, which you can then pass to codePointAt(0).
Code points are often written in hexadecimal, such as U+1F600; toString(16) converts the number into that form. In regular expressions, the u flag and \u{...} escapes work with whole code points in the same way.
Syntax
string.codePointAt(index)Parameters
- indexThe position, in UTF-16 code units.
Return Value
The Unicode code point at that position, or undefined if the index is out of range.
Example
Browser Support
The following information will show you the current browser support for the String.prototype.codePointAt() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





