Skip to content

Instantly share code, notes, and snippets.

@ericelliott
Created May 20, 2016 04:22
Show Gist options
  • Save ericelliott/4429bd470b8a6e85e43a88ff3869bbd0 to your computer and use it in GitHub Desktop.
Save ericelliott/4429bd470b8a6e85e43a88ff3869bbd0 to your computer and use it in GitHub Desktop.
Simple generator example
function* foo() {
yield 'a';
yield 'b';
yield 'c';
}
for (const val of foo()) {
console.log(val);
}
// a
// b
// c
const [...values] = foo();
console.log(values); // ['a','b','c']
@sibelius
Copy link

sibelius commented Jun 8, 2017

Because of yield and * generator syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment