This commit is contained in:
Ilya Kantor 2019-12-27 11:40:59 +03:00
parent 2483af0eda
commit 994390265a
5 changed files with 19 additions and 20 deletions

View file

@ -140,7 +140,7 @@ for(let value of generator) {
}
```
As generators are iterable, we can call all related functionality, e.g. the spread operator `...`:
As generators are iterable, we can call all related functionality, e.g. the spread syntax `...`:
```js run
function* generateSequence() {
@ -154,7 +154,7 @@ let sequence = [0, ...generateSequence()];
alert(sequence); // 0, 1, 2, 3
```
In the code above, `...generateSequence()` turns the iterable generator object into an array of items (read more about the spread operator in the chapter [](info:rest-parameters-spread-operator#spread-operator))
In the code above, `...generateSequence()` turns the iterable generator object into an array of items (read more about the spread syntax in the chapter [](info:rest-parameters-spread#spread-syntax))
## Using generators for iterables

View file

@ -120,11 +120,10 @@ Here's a small cheatsheet:
| `next()` return value is | any value | `Promise` |
| to loop, use | `for..of` | `for await..of` |
````warn header="The spread operator `...` doesn't work asynchronously"
````warn header="The spread syntax `...` doesn't work asynchronously"
Features that require regular, synchronous iterators, don't work with asynchronous ones.
For instance, a spread operator won't work:
For instance, a spread syntax won't work:
```js
alert( [...range] ); // Error, no Symbol.iterator
```