Created
July 6, 2015 18:04
-
-
Save jabez128/eadabe0602d2b4d5f9b2 to your computer and use it in GitHub Desktop.
generator mutilple entry
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 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