JavaScript (ES2026) reference · String Methods
JavaScript String codePointAt() Method
Return the full Unicode code point at an index, correctly handling emoji and other characters outside the BMP.
JavaScript (ES2026) Since ES2015
Syntax
string.codePointAt(index)
Parameters
| Parameter | Description |
|---|---|
index |
Position (in UTF-16 code units). |
Return value
A number, or undefined.
Examples
console.log("\u{1F42B}".codePointAt(0).toString(16));
Output
1f42b
for (const ch of "a\u{1F600}") {
console.log(ch.length, ch.codePointAt(0)); // each item is a whole character
}
Output
1 97 2 128512
Version history
| Version | Change |
|---|---|
| JavaScript ES2015 | Added |
In other languages
Related
string.charCodeAt()· Return the UTF-16 code unit (0 to 65535) at an index. For emoji and other astral characters use codePointAt().String.fromCodePoint()· Create a string from Unicode code points, including emoji outside the BMP that fromCharCode() can't express in one number.- JavaScript Strings · tutorial
- JavaScript String Methods · tutorial