Created
June 28, 2020 01:36
-
-
Save mactanxin/346e00309f3a38040b01cc33303429cd 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 generatePromiseFunc(index) { | |
return function () { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log(index) | |
resolve(index) | |
}, 1000) | |
}) | |
} | |
} | |
const promise_list = [] | |
for(let i = 0; i < 10; i++) { | |
promise_list.push(generatePromiseFunc(i)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment