May 2018
Intermediate to advanced
190 pages
2h 19m
English
ES6 brought a number of new features to the JavaScript language. Two of these features, generators and iterators, have substantially changed how we write specific functions in more complex front-end code.
While they do play nicely with each other, what they actually do can be a little confusing, so let’s check them out.
Iteration is a common practice in programming and is usually used to loop over a set of values, either transforming each value, or using or saving it in some way for later.
In JavaScript, we’ve always had for loops that look like this:
for (var i = 0; i < foo.length; i++){
// do something with i
}
But ES6 gives us an alternative:
for (const ...Read now
Unlock full access