Skip to content

Instantly share code, notes, and snippets.

@laser
Created November 26, 2013 19:17
Show Gist options
  • Save laser/7664335 to your computer and use it in GitHub Desktop.
Save laser/7664335 to your computer and use it in GitHub Desktop.
ES6 Generators
function* powGenerator() {
var result = Math.pow(yield "a", yield "b");
return result;
}
var g = powGenerator();
console.log(g.next().value); // "a", from the first yield
console.log(g.next(10).value); // "b", from the second
console.log(g.next(2).value); // 100, the result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment