FlashcardNot attempted
Iterator protocol
Recall it before you reveal
What makes an object iterable, and what does the iterator return?
Space to reveal
Show answer & explanation
Iterable: has a [Symbol.iterator]() method returning an iterator.
Iterator: has next() returning { value, done }. Optionally return(), which is called when a loop exits early (break/throw) so it can clean up.
Generators implement both automatically. Arrays, strings, Maps, Sets, arguments and NodeLists are built-in iterables; plain objects are not.