String.prototype.codePointAt()
Returns the Unicode code point value at the given index.
Syntax
str.codePointAt(pos) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pos | number | No | Zero-based position (in UTF-16 code units) of the character. Defaults to 0. |
Returns
number — The full code point as an integer, or undefined if the index is out of range.
Examples
console.log('A'.codePointAt(0));
Output
65
console.log('😀'.codePointAt(0));
Output
128512
Notes
Correctly returns the full code point for supplementary characters (emoji,
rare CJK), unlike `charCodeAt`. Returns undefined for out-of-range indices.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 41 |
| firefox | 29 |
| safari | 10 |
| edge | 12 |
| node | 4.0 |