ES6 Iteration Protocol
In this blog we focus on the iteration protocol introduced in ES6.
Lets take a quick programming 101 background. An iterator is basically a sequence generator. A sequence is an ordered list of values whose order and uniqueness does not matter. A trivial example of a sequence is the
So an iterator is just an abstraction of, for example, a
for loop. It has certain functions such as
value to go through the sequence, iterating through the elements.
We do the iteration to save memory by only generating values that are needed when they are needed. This is done by dynamically performing instructions based on the iteration.
Think about a for loop that ends when
i > 5 and
breaks; rather than going through the...
Continue reading →