Created
March 1, 2018 08:44
-
-
Save vldvel/7ae8b1d69b82e9a8fe9f5e8a409c26d4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 * withYield(a) { | |
let b = 5; | |
yield a + b; | |
b = 6; // it will be re-assigned after first execution | |
yield a * b; | |
} | |
const calcSix = withYield(6); | |
calcSix.next().value; // 11 | |
calcSix.next().value; // 36 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment