In this section, I'll introduce the generator function syntax, and we'll walk through yielding values from a generator. We'll also look at the two approaches that we can use to iterate over values yielded from generators.
The syntax for generator functions is nearly identical to normal functions. The difference in the declaration is that the
function keyword is followed by an asterisk. The more profound difference is the return value, which is always a generator instance. Moreover, there's no need for the
new keyword, despite a new object being created. Let's take a look at what a generator function looks like:
// Generator functions use an asterisk to // denote a that a generator ...