当前位置:网站首页>JS (in ES6) sync & await understanding
JS (in ES6) sync & await understanding
2022-07-29 05:00:00 【StackChan】
async function fun(){
console.log("2");
let a = await 7;
console.log("4");
let b = await new Promise((resolve,reject)=>{
setTimeout(function(){
resolve('setTimeout')
},3000)
})
console.log("5");
let c = await function(){
return 'function'
}()
console.log("6")
console.log(a,b,c)
console.log("8")
}
console.log("1")
fun(); // 3 Second output : 7 "setTimeout" "function"
console.log("3")
Running results :
1
2
3
4
appear :undefined The variable of , finger b
---
stop 3 second
----
5
6
7 'setTimeout' 'function'
8
thus it can be seen js(ES6 standard ) in async And await The running order of
Here first mark, Borrow a book another day , Multi research , Elaborate its principle ( Single thread ,js Run stack , browser API, Polling mechanism ,
from io Delay –> Synchronous and asynchronous requirements –> Several implementations of asynchrony : Callback function -- Callback hell problem leads to –>promise,then —>async+await,js The final solution of asynchrony )
Recently, I finished the small program development !
Thinking inspiration :
Find out in a few minutes Promise, Async, Await Usage of
边栏推荐
- Command line interactive tools (latest version) inquirer practical tutorial
- Operator operation list of spark
- def fasterrcnn_ resnet50_ FPN () instance test
- SparkSql批量插入或更新,保存数据到Mysql中
- Force deduction ----- sort odd and even subscripts respectively
- Introduction to auto.js script development
- Flutter 手势监听和画板实现
- Solution to the fourth game of 2022 Hangzhou Electric Multi school league
- 如何避免示波器电流探头损坏
- How to monitor micro web services
猜你喜欢
输入的查询SQL语句,是如何执行的?
Excel卡住了没保存怎么办?Excel还没保存但是卡住了的解决方法
The song of the virtual idol was originally generated in this way!
UE plays video in scene or UMG
Word如何查看文档修改痕迹?Word查看文档修改痕迹的方法
荣耀2023内推,内推码ambubk
How to solve the problem of configuring the progress every time Office2010 is opened?
Common current limiting methods
Sguard64.exe ace guard client exe: frequent disk reading and writing, game jamming, and Solutions
【微信小程序--解决display:flex最后一行对齐问题。(不连续排列会分到两边)】
随机推荐
Google browser opens the web page and out of memory appears
How does excel filter out the content you want? Excel table filtering content tutorial
Torch.nn.crossentropyloss() details
Spark的算子操作列表
带你搞懂 Kubernetes 集群中几种常见的流量暴露方案
What servers are needed to build mobile app
PHP判断用户是否已经登录,如果登录则显示首页,如果未登录则进入登录页面或注册页面
def fasterrcnn_ resnet50_ FPN () instance test
2021-10-23
The difference between the two ways of thread implementation - simple summary
Simple user-defined authentication interface rules
Operator operation list of spark
Deadlock to be resolved
How to avoid damage of oscilloscope current probe
【微信小程序】swiper滑动页面,滑块左右各露出前后的一部分,露出一部分
How to open IE browser by running win command
IOS interview preparation - Objective-C
ODOO开发教程之图表
Software test interview questions (4)
PHP determines whether the user has logged in. If logged in, the home page will be displayed. If not, enter the login page or registration page