Control flow
JavaScript has run-to-completion semantics, which means the sequence of instructions is executed from first to last. Conditional and looping statements change the flow. Functions get executed from the first instruction to the last, except when a return or an exception is encountered inbetween. Generators introduce a mechanism where control is switched back and forth between the calling code and the generator function. The calling code is the controller function. A generator function has multiple entry points. It resumes from where it gave control to the calling function or instruction.