Skip to content

Instantly share code, notes, and snippets.

@jabez128
Created July 6, 2015 18:04
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 jabez128/eadabe0602d2b4d5f9b2 to your computer and use it in GitHub Desktop.
Save jabez128/eadabe0602d2b4d5f9b2 to your computer and use it in GitHub Desktop.
generator mutilple entry
var log = console.log.bind(window.console);
function* powGenerator(){
var result = Math.pow(yield "first arg",yield "sendond arg");
return result;
}
var pow = powGenerator();
log(pow.next().value); // "first arg"
log(pow.next(10).value); // "second arg"
log(pow.next(2).value); // retuen 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment