Last active
August 29, 2015 14:01
-
-
Save marcusoftnet/2fbb9f6e84a3af983db0 to your computer and use it in GitHub Desktop.
Using the generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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