In JavaScript, there are several ways that control can be moved from one piece of code to another. Generally, code will be evaluated from left-to-right and top-to-bottom until it reaches any of the following situations:
- Invoking (invocation of a function by fn(), fn`` or new fn())
- Returning (returning from a function via either implicit or explicit return)
- Yielding (yielding from a generator via yield)
- Breaking (breaking from a loop or switch via break)
- Continuing (continuing an iteration via continue)
- Throwing (throwing an exception via throw)