In this episode of the hilarious Mattias P Johansson, he discusses JS iterators and builds a custom iterator.
What are Iterators
for ... of,
filter(). Behind all those JS is implementing Iterators object for you.
A typical iterator object has
next() method which is used to return the next item in the collection with two properties; done and value. These properties indicate if the items in the collections are used up or not, and the value at that point of iteration respectively.
Anyways, why am I boring you when you can watch mpj and learn iterators whilst doing a custom implementation.