-
-
Save ahamedali95/547edcb06952a8596bc38abf747d153a to your computer and use it in GitHub Desktop.
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() { | |
yield 'value1'; | |
console.log('I am here'); | |
yield 'value2'; | |
} | |
const g = generator(); //=> Object [Generator] {} | |
console.log(g.next()); //=> {value: "value1", done: false} | |
console.log(g.next()); | |
/** | |
* I am here | |
* {value: "value2", done: false} | |
**/ | |
console.log(g.next()); //=> {value: undefined, done: true} | |
console.log(g.next()); //=> {value: undefined, done: true} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment