QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 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 pointՃիշտ պատասխան
  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

Բացատրություն

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.

Շարունակեք այս թեստով

Սկսել վարժանքը
Հարց 101: When for...of iterates a string containing a character… · JavaScript Fundamentals · Questena