> For the complete documentation index, see [llms.txt](https://hemantajax-2.gitbook.io/es6-step-by-step/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hemantajax-2.gitbook.io/es6-step-by-step/generators.md).

# Generators

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

```javascript
// 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}
```
