nzakas / understandinges6

Content for the ebook "Understanding ECMAScript 6"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Potential Typo in Iterators & Generators chapter 8 - String Iterators

ronen-e opened this issue · comments

Issue 1:
In the section "String Iterators" the following sentence might be wrong (please notice the bold text):

But bracket notation works on code units rather than characters, so it cannot be used to access double-byte characters correctly

Reason:
characters in JavaScript are already double byte sized (UTF-16), so bracket notation works normally for them.
I believe the text should refer to surrogate pairs or double sized characters as the ones having issues.

Possible Solution

But bracket notation works on code units rather than characters, so it cannot be used to access surrogate pairs correctly

Issue 2:
The following section may also have an error:

This outputs the following:

A
(blank)
𠮷
(blank)
B

This result is more in line with what you'd expect when working with characters: the loop successfully prints the Unicode character, as well as all the rest.

Reason:
All the characters are Unicode characters.

Solution
Switch the term Unicode character with something like surrogate pair / astral symbol/ astral code point / double sized character

I think "surrogate pair" is the best option in both cases because this term was already used in chapter 2.