In the previous section, we traversed many different collections, even nested ones. Now, it's time to learn more about the iterator pattern. This pattern especially shines if you plan to use the Redux Saga library.
If you jumped straight to this chapter, I highly advise you to read the section that introduces iterator patterns in Chapter 6, Data Transfer Patterns. That chapter also covers the Redux Saga library and generators.
To recap, in JavaScript, an iterator is an object that knows how to traverse items of a collection one at a time. It must expose the next() function, which returns the next item of a collection. The collection can be whatever it wants. It can even be an infinite collection, such as the Fibonacci numbers, as seen here:
class FibonacciIterator {
constructor() {
this.n1 = 1;
this.n2 = 1;
}
next() {
var...