Javascript - Generator-Yield/Next & Async-Await
Deepak Gupta
3K8

Reading your article gave me the impression that generator functions execute until they hit the yield keyword and then wait for next to be called:

> Once paused on a yield expression, the generator's code execution remains paused until the generator's next() method is called.

It is easy to verify that all execution of generator functions is deferred until a call to yield is made, which is different, though admittedly only when side effects are involved.

Here’s an example in which you can easily verify that the alert will not fire:

(function* myGenerator() { alert('executed'); yield true })()