Skip to content

Instantly share code, notes, and snippets.

@marcusoftnet
Last active August 29, 2015 14:01
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 marcusoftnet/2fbb9f6e84a3af983db0 to your computer and use it in GitHub Desktop.
Save marcusoftnet/2fbb9f6e84a3af983db0 to your computer and use it in GitHub Desktop.
Using the generator
var elvis = theGenerator(); // get an instance of the generator
console.log(elvis.next().value); // outputs "One, for the money”
console.log(elvis.next().value); // outputs "Two, for the show"
console.log(elvis.next().value); // outputs "Three to get ready! Now go, cat, go"
/*
console.log(elvis.next()); // ouputs { value: undefined, done: true }
console.log(elvis.next()); // throws Error: Generator has already finished*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment