Posted On: Feb 22, 2018
Generators are functions that can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances. A function keyword followed by an asterisk defines a generator function, which returns a Generator object.
Generator Function Example.
function* generator(i) { yield i; yield i + 10; } var gen = generator(10); console.log(gen.next().value); // expected output: 10 console.log(gen.next().value);
Further reading: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*
Never Miss an Articles from us.
Es6 or ECMASCRIPT 2015 is sixth major release of ECMAScript language which comes with a lot of new features and syntax..
New Features in ES6. Support for constants (also known as “immutable variables”) Block-Scope support for both varia..
Babel is one of the most popular JavaScript transpilers and becomes the industry standard. It allows us to write ES6 cod..