@@ -121,7 +121,7 @@ Arrays and strings are most widely used built-in iterables.
121121For a string, ` for..of ` loops over its characters:
122122
123123``` js run
124- for (let char of " test" ) {
124+ for (let char of " test" ) {
125125 alert ( char ); // t, then e, then s, then t
126126}
127127```
@@ -130,16 +130,16 @@ And it works right with surrogate pairs!
130130
131131``` js run
132132let str = ' 𝒳😂' ;
133- for (let char of str) {
134- alert (char); // 𝒳, and then 😂
133+ for (let char of str) {
134+ alert ( char ); // 𝒳, and then 😂
135135}
136136```
137137
138138## Calling an iterator explicitly
139139
140140Normally, internals of iterables are hidden from the external code. There's a ` for..of ` loop, that works, that's all it needs to know.
141141
142- But to understand things a little bit more deeper let's see how to create an iterator explicitly.
142+ But to understand things a little bit deeper let's see how to create an iterator explicitly.
143143
144144We'll iterate over a string the same way as ` for..of ` , but with direct calls. This code gets a string iterator and calls it "manually":
145145
@@ -151,7 +151,7 @@ let str = "Hello";
151151
152152let iterator = str[Symbol .iterator ]();
153153
154- while (true ) {
154+ while (true ) {
155155 let result = iterator .next ();
156156 if (result .done ) break ;
157157 alert (result .value ); // outputs characters one by one
@@ -184,7 +184,7 @@ let arrayLike = { // has indexes and length => array-like
184184
185185* ! *
186186// Error (no Symbol.iterator)
187- for (let item of arrayLike) {}
187+ for (let item of arrayLike) {}
188188*/ ! *
189189```
190190
@@ -258,7 +258,7 @@ Technically here it does the same as:
258258let str = ' 𝒳😂' ;
259259
260260let chars = []; // Array.from internally does the same loop
261- for (let char of str) {
261+ for (let char of str) {
262262 chars .push (char);
263263}
264264
0 commit comments