QuestenaÜben und erkennen, was als Nächstes dran ist
Frage 101

When for...of iterates a string containing a character represented by one UTF-16 surrogate pair, how is that pair handled?

  1. The pair is consumed together as one code pointRichtige Antwort
  2. Each code unit always becomes a separate iteration
  3. The loop throws because the string contains two code units
  4. The pair is skipped because only ASCII characters are iterable

Erklärung

String iteration advances by Unicode code point, so the two code units of a valid surrogate pair are delivered together for that code point. Treating every code unit as a separate iteration confuses for...of with direct UTF-16 indexing; a code point still need not equal a full grapheme.

Mit diesem Test weitermachen

Übung starten
Frage 101: When for...of iterates a string containing a character… · JavaScript Fundamentals · Questena