With the launch of ES6, a new way of working with functions and iterators came into work. These are called generators. A generator is nothing but a function that can stop at the point of time when the user commands it to do so and then continue working just from the point where it stopped. In other words, a generator has properties of a function but also works as an iterator. It does not work like other lines of code which need to be completed for execution.

Generators work on a run-to-completion model which makes it easier for the developers to compile a program. Generators can also be defined as a special class of functions that work to simplify the task of coding iterators in a program. It produces a sequence of results rather than producing a single value. It enables the developer to generate a series of values at a time.

This is very important javascript ES6 Interview Questions.

BY Best Interview Question ON 06 Oct 2019