ES6 generators to the rescue

Arrays are one of the simplest data structures which allow access to a list of elements. JavaScript (and most programming languages) has the notion of array. However one of the problems related to arrays is they are constrained by their size, i.e. an array has a limited number of elements. Furthermore, when applying functions to arrays, one passes the whole data structure at once. Let’s take a look at the following example. The map function is applied to the whole array and the result is calculated right away.

Note, the lambda expression is part of ES6

Continue Reading…