Created
February 16, 2017 17:40
-
-
Save thecrogers/0c20d4da734e58ac07ad72d141cbf02d to your computer and use it in GitHub Desktop.
Basic es6 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
function* Generator() { | |
let someVar = 'Hi'; | |
yield someVar; | |
} | |
let it = Generator(); | |
console.log(it.next()); | |
//output: {done: false, value: 'Hi'}; | |
console.log(it.next()); | |
//output: {done: true, value: null} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment