minor fixes
This commit is contained in:
parent
bae0ef44d0
commit
0f748275e2
1 changed files with 4 additions and 4 deletions
|
@ -31,7 +31,7 @@ To make the `range` object iterable (and thus let `for..of` work) we need to add
|
|||
1. When `for..of` starts, it calls that method once (or errors if not found). The method must return an *iterator* -- an object with the method `next`.
|
||||
2. Onward, `for..of` works *only with that returned object*.
|
||||
3. When `for..of` wants the next value, it calls `next()` on that object.
|
||||
4. The result of `next()` must have the form `{done: Boolean, value: any}`, where `done=true` means that the iteration is finished, otherwise `value` is the next value.
|
||||
4. The result of `next()` must have the form `{done: Boolean, value: any}`, where `done=true` means that the loop is finished, otherwise `value` is the next value.
|
||||
|
||||
Here's the full implementation for `range` with remarks:
|
||||
|
||||
|
@ -45,7 +45,7 @@ let range = {
|
|||
range[Symbol.iterator] = function() {
|
||||
|
||||
// ...it returns the iterator object:
|
||||
// 2. Onward, for..of works only with this iterator, asking it for next values
|
||||
// 2. Onward, for..of works only with the iterator object below, asking it for next values
|
||||
return {
|
||||
current: this.from,
|
||||
last: this.to,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue