I'm led to believe that Promise.all executes all the functions you pass it in parallel and doesn't care what order the returned promises finish.
But when I write this test code:
function Promise1(){
return new Promise(function(resolve, reject){
for(let i = 0; i < 10; i++){
console.log("Done Err!");
}
resolve(true)
})
}
function Promise2(){
return new Promise(function(resolve, reject){
for(let i = 0; i < 10; i++){
console.log("Done True!");
}
resolve(true)
})
}
Promise.all([
Promise1(),
Promise2()
])
.then(function(){
console.log("All Done!")
})
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…