Removing Noise With Yield
Explore how to use the yield keyword in JavaScript to create efficient iterators. Learn how yield pauses and resumes function execution, making iterator code more fluent and less nested for better control and clarity.
We'll cover the following...
We'll cover the following...
Introduction
Let’s put the role of the iterator method, introduced in the previous lesson into words. As the caller iterated over the object, the iterator yielded the next value. To achieve that, we wrote quite a bit of code. We can get rid of most of the extraneous code using the special yield keyword.
Using yield
The ...