JavaScript Unicode Escapes

JavaScript strings can contain Unicode characters literally or through escape syntax. Basic Multilingual Plane characters can use \uXXXX. Modern code-point escapes use \u{...} and can represent supplementary characters directly.

Escape Formats

CharacterLiteralClassic escapeCode-point escape
©"©""\u00A9""\u{A9}"
"✓""\u2713""\u{2713}"
😀"😀""\uD83D\uDE00""\u{1F600}"

Why Emoji Needed Surrogate Pairs

Traditional \uXXXX syntax contains exactly four hexadecimal digits, so supplementary code points are represented by two UTF-16 surrogate code units. Code-point escape syntax avoids that split and is easier to compare with U+ notation.

Iterate by Code Point, Not Code Unit

Array.from(text), spread syntax, and for...of iterate by Unicode code point. Direct string indexing and the length property operate on UTF-16 code units, which can split supplementary characters.