iterators and iterables, a quick recapitulationIn JavaScript, iterators and iterables provide an abstract interface for sequentially accessing values, such as we might find in collections like arrays or priority queues.1An iterator is an object with a.next()method. When you call it, you get a Plain Old JavaScript Object (or “POJO”) that has adoneproperty. If the value ofdoneisfalse, you are also given avalueproperty that represents, well, a value. If the value ofdoneistrue, you may or may not be given avalueproperty.Iterators are stateful by design: Repeatedly invoking the.next()method usually
...
继续阅读
(31)