Skip to content

Instantly share code, notes, and snippets.

@vldvel
Created March 1, 2018 14:36
Show Gist options
  • Save vldvel/5049ad1f96304e4b4cf7fc671ffcf391 to your computer and use it in GitHub Desktop.
Save vldvel/5049ad1f96304e4b4cf7fc671ffcf391 to your computer and use it in GitHub Desktop.
function * generator() {
yield 1;
yield 2;
yield 3;
}
const gen = generator();
gen.return(); // {value: undefined, done: true}
gen.return('Heeyyaa'); // {value: "Heeyyaa", done: true}
gen.next(); // {value: undefined, done: true} - all next() calls after return() will return the same output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment