Generators Simple pause resume - Coding Blast - www.codingblast.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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