In JavaScript, a generator is a special type of function that can be paused and resumed during its execution. It allows you to define an iterative algorithm by writing a function that can maintain its internal state and produce a sequence of values over time.
Generators are defined using a function syntax with an asterisk ``++(*)++`` appended to the ``++function++`` keyword (``++function*++``). Within the generator function, you can use the ``++yield++`` keyword to produce a value and temporarily pause the execution of the function, returning that value to the consumer.
Using a generator without the ``++yield++`` keyword can limit the usefulness and potential benefits of generators. When you use the ``++yield++`` keyword without providing a value, it creates a yield expression that pauses the execution of the generator function and returns ``++undefined++`` as the yielded value.
Yielding without a value makes it harder for the generator consumer to understand the purpose or context of the yielded value. Instead, one should always provide an explicit value with ``++yield++`` (using `undefined` when that is the intention) to make the generated sequence more meaningful and informative.
\[~ann.campbell.2] Could you add to description smth like "It even could be a bug in your problem as you your iterator produced by this generator function is always empty"?
And I would like to remove highlighting and specific message for return, I don't think it's worth that. Are you ok?