当前位置:网站首页>[JS advanced] promise explanation
[JS advanced] promise explanation
2022-07-01 12:13:00 【Wangzai liunai】
Back to hell
promise promise
Fulfill your promise Promises sink into the sea Promise to wait for the result ……
resolve solve the problem
reject Refuse to consider
pending Wait for
A means to solve asynchronous process .
Promise It's a constructor need new
Promise Parameters excutor actuator
excutor -> resolve reject function
excutor new Promise call
// excutor It's synchronous
let promise = new Promise((resolve,reject)=>{
console.log(1);
})
console.log(2);
// then Is an asynchronous call excutor It's synchronous .
then Is an asynchronous call .
pending -> resolve
pending -> reject
Only in this way .
Promise.all([promise1,promise2,promise3])
Multiple asynchronous tasks run concurrently , Its results are used after creating commitments , Wait for all task results to be completed .
iterable The internal elements pass promise A collection of objects , If not promise, direct resolve Return the value to
iterable There are no elements inside , Just return an empty array .
Just one of them promise yes rejected In terms of state , Then the instance callback is rejected.
The reason for the failure is the first one promise Result
Promise.race()
Whoever finishes first will return to that promise Result , Success or failure (fullfilled perhaps rejected)
Test the response speed of resources or interfaces
async await
await Is an operator , Waiting for one Promise The operation means for the object to produce results
Function is pause async Execution of a function , wait for promise The result of the treatment .
If Promise The result is rejected, It throws an exception
acync Functions are implicit Promise return pending state
async It means that the current asynchronous function and the program under the same scope are asynchronous .
边栏推荐
- Joint Time-Frequency and Time Domain Learning for Speech Enhancement
- Self organization is the two-way rush of managers and members
- 力扣首页简介动画
- [MCU] [nixie tube] nixie tube display
- Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS
- [shell programming] - shell introductory learning
- The Missing Semester
- Rural guys earn from more than 2000 a month to hundreds of thousands a year. Most brick movers can walk my way ǃ
- 研发效能度量框架解读
- Istio, ebpf and rsocket Broker: in depth study of service grid
猜你喜欢

LeetCode力扣(剑指offer 31-35)31. 栈的压入弹出序列32I.II.III.从上到下打印二叉树33. 二叉搜索树的后序遍历序列34. 二叉树中和为某一值的路径35. 复杂链表的复制

91. (chapitre Cesium) simulation de lancement de fusées cesium

华为HMS Core携手超图为三维GIS注入新动能

Machine learning - Data Science Library Day 3 - Notes

栈-------

比特熊直播间一周年,英雄集结令!邀你来合影!
![[classic example] classic list questions @ list](/img/d8/a259e5f9d08eacbef31254d1bc3304.jpg)
[classic example] classic list questions @ list

The Missing Semester

Uniapp uses uni upgrade Center
![[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 3](/img/ea/c5e8d12007873385fa0d197fa62fd2.jpg)
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 3
随机推荐
Botu V15 add GSD file
[MCU] [nixie tube] nixie tube display
easyexcel的使用
构建外部模块(Building External Modules)
基于IMDB评论数据集的情感分析
Summary of JFrame knowledge points 1
ACLY与代谢性疾病
Use set_ Handler filters out specific SystemC wrapping & error messages
Typora adds watermarks to automatically uploaded pictures
Explore the contour detection function findcontours() of OpenCV in detail with practical examples, and thoroughly understand the real role and meaning of each parameter and mode
消息队列之监控退款任务批处理过程
Personnaliser le plug - in GRPC
Mysql database knowledge collation
Theoretical basis of graph
Acly and metabolic diseases
【20211129】Jupyter Notebook遠程服務器配置
[106] 360 check font - check whether the copyright of local Fonts is commercially available
AI抠图工具
91. (chapitre Cesium) simulation de lancement de fusées cesium
栈的应用——括号匹配问题