Skip to content

Instantly share code, notes, and snippets.

@vldvel
Created March 1, 2018 14:15
Show Gist options
  • Save vldvel/30e8bed5bc407be90cfd295e049c9199 to your computer and use it in GitHub Desktop.
Save vldvel/30e8bed5bc407be90cfd295e049c9199 to your computer and use it in GitHub Desktop.
function * generator() {
yield 1;
yield 2;
yield 3;
}
const gen = generator();
gen.next(); // {value: 1, done: false}
gen.next(); // {value: 2, done: false}
gen.next(); // {value: 3, done: false}
gen.next(); // {value: undefined, done: true} and all next calls will return the same output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment