Created
December 10, 2018 19:38
-
-
Save guest271314/c42ce434665b6a47e1465d83eb99b946 to your computer and use it in GitHub Desktop.
generator-with-indexes.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
// https://stackoverflow.com/questions/53687210/how-to-iterate-over-a-generator-with-indexes | |
function* myGen(){ | |
let i = 10; | |
while(i<20) { | |
i+=1; | |
yield i; | |
} | |
} | |
for(let [index, j] of [...myGen()].entries()) { //<-- I want .entries() but for a Generator | |
console.log(index, j) | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment