Generators

we have to install "babel-polyfill" to use this feature with webpack

// in webpack.config.js add below entry
// entry: ['babel-polyfill', './main.js'],
function* generateMe(){
yield "One";
yield "Two";
yield [1,2,3];
}
var generator = generateMe();
console.log(generator.next());
console.log(generator.next());
console.log(generator.next());
console.log(generator.next());
// Output
// { value="One", done=false}
// { value="Two", done=false}
// { value=[3], done=false}
// { done=true, value=undefined}