当前位置:网站首页>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()
})
边栏推荐
- Vscode set JSON file to format automatically after saving
- Blender stone carving
- How to judge the quality of primary market projects when the market is depressed?
- 07 data import sqoop
- Commutateur Multi - lentilles Blender
- Project practice, redis cluster technology learning (VII)
- Blender摄像机环绕运动、动画渲染、视频合成
- ERROR 1118 (42000): Row size too large (> 8126)
- [IDL] Research
- Sum the two numbers to find the target value
猜你喜欢
Blender stone carving
The primary market project galaxy will conduct public offering on coinlist on February 17
Bookmark collection management software suspension reading and data migration between knowledge base and browser bookmarks
Message mechanism -- getting to know messages and message queues for the first time
Ue5 - ai Pursuit (Blueprint, Behavior tree)
Allure -- common configuration items
What is the relationship between realizing page watermarking and mutationobserver?
MongoDB-快速上手MongoDB命令行的一些简单操作
Ue5 - AI pursuit (blueprint, behavior tree)
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
随机推荐
[illusory] automatic door blueprint notes
[MySQL] an exception occurs when connecting to MySQL: connection must be valid and open
Excuse me, is it cost-effective to insure love life patron saint 2.0 increased lifelong life insurance? What are the advantages of this product?
虚幻AI蓝图基础笔记(万字整理)
合并有序数列
Flink calculates topn hot list in real time
Delivery mode design of Spartacus UI of SAP e-commerce cloud
[unity3d] cannot correctly obtain the attribute value of recttransform, resulting in calculation error
Applet development summary
MongoDB-快速上手MongoDB命令行的一些简单操作
pytest框架实现前后置
判断数组中是否存在重复元素
[pit avoidance guide] pit encountered using ugui: the text component cannot indent the first line by two spaces
Basic notes of illusory AI blueprint (10000 words)
Project practice, redis cluster technology learning (12)
[Lua] summary of common knowledge points (including common interview sites)
Pytest-- test report allure configuration
SQOOP 1.4.6 INSTALL
Edge computing accelerates live video scenes: clearer, smoother, and more real-time
This article takes you to learn in detail what is fiber to home FTTH