Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created April 26, 2017 16:20
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 Ibro/a1ddce0f19a303abecebd5ebe55e8f61 to your computer and use it in GitHub Desktop.
Save Ibro/a1ddce0f19a303abecebd5ebe55e8f61 to your computer and use it in GitHub Desktop.
Generators Simple pause resume - Coding Blast - www.codingblast.com
function* print() {
let a = 5 - (yield 3);
console.log('a:', a);
}
let generator = print();
let iteratorResult = generator.next(); // sending value in next here gets ignored during first next
console.log(iteratorResult);
iteratorResult = generator.next(1);
console.log(iteratorResult);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment