Unicode in JavaScript
summary
JavaScript represents astral Unicode as surrogate pairs, so many symbols (emoji, math alphas, pile of poo) consume two code units and string.length counts halves, breaking counters, reversing, substring and regex expectations. Workarounds include normalizing combining sequences and iterating code points rather than code units, polyfills that implement String.fromCodePoint and codePointAt, and tools that generate Unicode-aware regex. ECMAScript 6 adds for‑of, normalization and a Unicode /u flag to fix many issues.
AI-written summary · about
chapters (15)
- 0:00Start
- 5:59Hexadecimal escape sequences
- 6:53Unicode escape sequences
- 8:01Unicode code point escapes
- 8:32Surrogate pairs
- 10:00JavaScript string length
- 11:28Real-world example
- 13:19JS string character count
- 14:21If we're being pedantic...
- 15:50Unicode normalization
- 16:46Reversing a string in JavaScript
- 20:42Iterate over all symbols in a string
- 21:24More string madness
- 21:56Match any Unicode symbol
- 22:57Create Unicode-aware regular expressions








