JS Built-ins
StringString.prototype.codePointAtintermediate

String.prototype.codePointAt() β€” vs charCodeAt for BMP

πŸ“– Usage Example
const str = 'Hello'
str.codePointAt(0)     // β†’ 72
'πŸ˜€'.codePointAt(0)    // β†’ 128512

Use codePointAt() to get the full Unicode code point at a position, correctly handling supplementary characters.

codePointAt vs charCodeAt

For BMP characters, both methods return the same value. For supplementary characters, they differ at position 0.

Challenge: Implement codesMatch(str, pos) that returns true when .codePointAt(pos) equals .charCodeAt(pos).

codesMatch('A', 0)  // β†’ true
codesMatch('πŸ˜€', 0) // β†’ false
πŸ’‘ Hints (1)
  • β€’ BMP code points (0–65535) are the same in both methods. Supplementary code points differ.