Skip to content

Instantly share code, notes, and snippets.

@OleksivO
Created January 16, 2019 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OleksivO/2e1d88bc9f77171444dad262ab759edb to your computer and use it in GitHub Desktop.
Save OleksivO/2e1d88bc9f77171444dad262ab759edb to your computer and use it in GitHub Desktop.
the description for this gist
function* generatorFunction() {
yield 'First value';
yield 'Second value';
return 'Third value';
}
const iteratorObject = generatorFunction();
console.log(iteratorObject.next()) //{value: "First value", done: false}
console.log(iteratorObject.next()) //{value: "Second value", done: false}
console.log(iteratorObject.next()) // {value: "Third value", done: true}
console.log(iteratorObject.next()) // {value: "undefined, done: true}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment