promise的all和race的效果对比
function fun1(){
return new Promise(_=>{
setTimeout(()=>{
_("1")
},1000)
})
}
function fun2(){
return new Promise(_=>{
setTimeout(()=>{
_("2")
},2000)
})
}
Promise.all([fun1(),fun2()]).then((ret)=>{
console.log("all",ret);
})
Promise.race([fun1(),fun2()]).then((ret)=>{
console.log("rece",ret);
})