Last active
November 14, 2017 17:35
-
-
Save cyan33/ee69e6a166d130efac07a2497a0eb70b to your computer and use it in GitHub Desktop.
basic generator example
This file contains hidden or 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
function *makeGenerator() { | |
yield 1; | |
yield 3; | |
yield 5; | |
} | |
var gen = makeGenerator(); | |
gen.next() // { done: false, value: 1 } | |
gen.next() // { done: false, value: 3 } | |
gen.next() // { done: false, value: 5 } | |
gen.next() // { done: true, value: undefined } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment