Skip to content

Instantly share code, notes, and snippets.

@Mayankgupta688
Last active May 17, 2019 07:39
Show Gist options
  • Select an option

  • Save Mayankgupta688/ca5c4d81a5188fbef47da8aeddbc0386 to your computer and use it in GitHub Desktop.

Select an option

Save Mayankgupta688/ca5c4d81a5188fbef47da8aeddbc0386 to your computer and use it in GitHub Desktop.
function* customGenerator() {
yield 1;
return 5;
yield 2;
}
let getIterator = customGenerator();
let nextValue = null;
nextValue = getIterator.next();
console.log(nextValue);
// Output is: { value: 1, done: false }
nextValue = getIterator.next();
console.log(nextValue);
// Output is: { value: 5, done: true }
nextValue = getIterator.next();
console.log(nextValue);
// Output is: { value: undefined, done: true }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment