0
点赞
收藏
分享

微信扫一扫

promise的all和race的效果对比


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);
})


举报

相关推荐

0 条评论