Created
October 4, 2018 15:32
-
-
Save hg-pyun/a4f2da306d9f6152efda23b217402444 to your computer and use it in GitHub Desktop.
iterator.07.js
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* idMaker(){ | |
var index = 0; | |
while(index < 3) | |
yield index++; | |
} | |
const gen = idMaker(); | |
console.log(gen.next().value); // 0 | |
console.log(gen.next().value); // 1 | |
console.log(gen.next().value); // 2 | |
console.log(gen.next().value); // undefined | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment