In JavaScript, generators are those functions which can be exited and re-entered later on. Their variable bindings shall be saved across the re-entrances. They are written using the function* syntax.

The Generator function should be used when:
  • You can choose to jump out of a function and let the outer code determine when to jump back in the function.
  • The control of the asynchronous call can be executed outside of your code.

JavaScript is a high-level, multi-paradigm programming language which conforms to the ECMAScript specification. Read our list of advanced javascript interview questions to get a deep understanding of this language.

BY Best Interview Question ON 20 Jun 2020