What is a generator function in JavaScript?
A generator function is declared with function* and can pause and resume its execution using the yield keyword. Calling a generator function does not immediately execute its body; it returns a generator object that implements the iterator protocol.