当前位置:网站首页>js promise.all
js promise.all
2022-07-02 06:41:00 【大鸡腿最好吃】
let d= promise.all([a,b,c])
接受一个promise数组,只有数组里面的promise全部成功才返回成功,要不就失败
只有a、b、c的状态都变成fulfilled,d的状态才会变成fulfilled,此时a、b、c的返回值组成一个数组,传递给d的回调函数。
只要a、b、c之中有一个被rejected,d的状态就变成rejected,此时第一个被reject的实例的返回值,会传递给p的回调函数。
面试题
函数c在函数a和b执行完后才执行
就使用promise.all
let a=function(){
console.log('a')
}
let b=function(){
console.log('b')
}
let p1 = new Promise((resolve, reject) => {
a()
resolve('成功了')
})
let p2 = new Promise((resolve, reject) => {
b()
resolve('success')
})
let c=function(){
console.log('c')
}
Promise.all([p1, p2]).then((result) => {
c()
})
边栏推荐
- [leetcode] sword finger offer 53 - I. find the number I in the sorted array
- Considerations for Apache deploying static web page projects
- What is call / cc- What is call/cc?
- 07 data import sqoop
- 使用Windbg静态分析dump文件(实战经验总结)
- Webui automated learning
- Flink calculates topn hot list in real time
- Project practice, redis cluster technology learning (11)
- UE illusory engine programmed plant generator setup -- how to quickly generate large forests
- 网络通信学习
猜你喜欢
![[unreal] animation notes of the scene](/img/97/dafde0377b7c4337e1775db64ba6a4.png)
[unreal] animation notes of the scene

Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer

ue虛幻引擎程序化植物生成器設置——如何快速生成大片森林

Ue5 - ai Pursuit (Blueprint, Behavior tree)

STM32 and motor development (upper system)

Blender model import UE, collision settings

Postman--使用

Postman -- use

Blender multi lens (multi stand) switching

ue虚幻引擎程序化植物生成器设置——如何快速生成大片森林
随机推荐
SQOOP 1.4.6 INSTALL
Solutions to a series of problems in sqoop job creation
[MySQL] an exception occurs when connecting to MySQL: connection must be valid and open
VLAN experiment
[Lua] summary of common knowledge points (including common interview sites)
网络通信学习
Brief analysis of edgedb architecture
Project practice, redis cluster technology learning (VII)
Network communication learning
传输优化抽象
Rapid prototyping
Remember the use of add method once
【避坑指南】Unity3D项目接入腾讯Bugly工具时遇到的坑
Commutateur Multi - lentilles Blender
Nonlinear optimization: steepest descent method, Newton method, Gauss Newton method, Levenberg Marquardt method
[illusory] automatic door blueprint notes
How to achieve the top progress bar effect in background management projects
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
Ue5 - ai Pursuit (Blueprint, Behavior tree)
Configuration programmée du générateur de plantes du moteur illusoire UE - - Comment générer rapidement une grande forêt