Closed ronen-e closed 3 years ago
Yeah, that seems like a typo. Thanks.
Okay, so this one is a bit tricky. The for-of
loop technically works on iterables. It creates an iterator for the iterable and then calls next()
on that. So the correct sentence might look like this:
A
for-of
loop works on an iterable and uses itsSymbol.iterator
property to retrieve an iterator. Then, thefor-of
loop callsnext()
on that iterator each time the loop executes and stores the value from the result object in a variable.
@nzakas 👍
btw, glad to hear you're feeling better
In chapter 8 under the section "Iterables and for-of" - there seems to be a typo in the sentence
However Iterable objects are not required to implement a
next()
method.The for-of loop uses
[Symbol.iterator]()
on the iterable only to obtain the iterator object and then consume the iterator.I think the correct terminology is to use iterator instead, like: