Last active
October 12, 2017 14:44
-
-
Save yancya/beb8c131d0fc1b33fe4bfcab940c70ee 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 times(n) { | |
const iterator = (function* gen(n) { | |
let count = 0; | |
while (count < n) { | |
yield count; | |
count++; | |
} | |
})(n); | |
return Array.from(iterator); | |
} | |
times(3).forEach(()=>console.log('hoge')); | |
for(let i of times(3)) { console.log('hoge'); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment