Skip to content

Instantly share code, notes, and snippets.

@thecrogers
Created February 16, 2017 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thecrogers/0c20d4da734e58ac07ad72d141cbf02d to your computer and use it in GitHub Desktop.
Save thecrogers/0c20d4da734e58ac07ad72d141cbf02d to your computer and use it in GitHub Desktop.
Basic es6 generator
function* Generator() {
let someVar = 'Hi';
yield someVar;
}
let it = Generator();
console.log(it.next());
//output: {done: false, value: 'Hi'};
console.log(it.next());
//output: {done: true, value: null}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment