StringprototypecodePointAt
String.prototype.codePointAt is a JavaScript method that returns the Unicode code point value at a given position in a string. It is part of the String.prototype object and was introduced with ECMAScript 2015 (ES6) to provide robust handling of characters outside the Basic Multilingual Plane through proper treatment of UTF-16 surrogate pairs.
The method accepts a single argument, position, which is coerced to an integer index. If the index
Common use cases include obtaining exact code point values for individual characters, iterating over strings by
- "ABC".codePointAt(0) yields 65.
- "💩".codePointAt(0) yields 0x1F4A9 (128169 in decimal).