InterviewSolution
| 1. |
What Is Koa.js Generators? |
|
Answer» One of the most exciting new features coming in JavaScript ES6 is a new breed of function, called a generator. Before generators, the whole script used to usually execute in a top to bottom order, without an easy way to stop code execution and resuming with the same stack LATER. Generators are functions which can be EXITED and later re-entered. Their context (variable BINDINGS) will be saved ACROSS re-entrances. Generators allow us to stop code execution in between. So LETS have a look at a simple generator: var generator_func = function* (){ One of the most exciting new features coming in JavaScript ES6 is a new breed of function, called a generator. Before generators, the whole script used to usually execute in a top to bottom order, without an easy way to stop code execution and resuming with the same stack later. Generators are functions which can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances. Generators allow us to stop code execution in between. So lets have a look at a simple generator: var generator_func = function* (){ |
|