Created
March 14, 2017 04:09
-
-
Save ianaya89/8289cb8999e7f18e8e7d8146a4f43842 to your computer and use it in GitHub Desktop.
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(true) | |
yield index++; | |
} | |
var gen = idMaker(); | |
console.log(gen.next().value); // 0 | |
console.log(gen.next().value); // 1 | |
console.log(gen.next().value); // 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment