Iterable Sequences with Generators and Iterators

Raju Gandhi · Apress eBooks · 2019

Storing and manipulating data in collections in JavaScript is not only easy, but also elegant. However, iterating is another matter. Consider arrays. In order to iterate and fetch the elements of an array, we use contrived syntax like the for (let i = 0; i < array.length; i++) loop, or even worse, the for-in loop. But that’s not the end of it! Every so often we will have custom objects that might need iteration. We concede defeat, and build (or consume) a custom API (think array.forEach ) just so we can get each element in a particular sequence.

Read the paper · More papers on PaperTik