This commit is contained in:
Ilya Kantor 2019-07-18 12:24:31 +03:00
parent 0b55d45daf
commit 3caa91137e
8 changed files with 21 additions and 33 deletions

View file

@ -1,4 +1,3 @@
# Generators
Regular functions return only one, single value (or nothing).
@ -224,8 +223,6 @@ let range = {
alert( [...range] ); // 1,2,3,4,5
```
The `range` object is now iterable.
That works, because `range[Symbol.iterator]()` now returns a generator, and generator methods are exactly what `for..of` expects:
- it has `.next()` method
- that returns values in the form `{value: ..., done: true/false}`