Skip to content

Instantly share code, notes, and snippets.

@ahamedali95
Last active May 10, 2020 20:15
Show Gist options
  • Save ahamedali95/547edcb06952a8596bc38abf747d153a to your computer and use it in GitHub Desktop.
Save ahamedali95/547edcb06952a8596bc38abf747d153a to your computer and use it in GitHub Desktop.
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