Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created April 26, 2017 16:20
Embed
What would you like to do?
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