Skip to content

Instantly share code, notes, and snippets.

@mactanxin
Created June 28, 2020 01:36
Show Gist options
  • Save mactanxin/346e00309f3a38040b01cc33303429cd to your computer and use it in GitHub Desktop.
Save mactanxin/346e00309f3a38040b01cc33303429cd to your computer and use it in GitHub Desktop.
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