## Description
A *Generator Function* builds off of the [[Iterable Protocol|iterable]] and [[Iterator Protocol|iterator]] protocols.
## Qualities
- *Generators* are functions that can be exited and re-entered later
- *Generators* can pause and resume
- *Generators* inherently support `async` operations, and `async` functions are essentially [[syntactical sugar]] on top of *generators*
```JavaScript
function doOperations() {
yield 2;
yield 3;
yield 4;
}
doOperations();
```
Calling `doOperations()` results in nothing happening and instead need to call `.next()`
## See Also
- [[Iterable Protocol]]
- [[Iterator Protocol]]
## References
- [Iterators and Generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators)
- [Use Cases for JavaScript Generators - Dev.to](https://dev.to/rfornal/use-cases-for-javascript-generators-1npc)
- [JavaScript Generator Practical Use Cases - Better Programming](https://betterprogramming.pub/javascript-generators-practical-use-cases-945d512ef252)