当前位置:网站首页>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
边栏推荐
- Mysql:The user specified as a definer (‘root‘@‘%‘) does not exist 的解决办法
- How does excel filter out the content you want? Excel table filtering content tutorial
- Implementation of flutter gesture monitoring and Sketchpad
- Big silent event Google browser has no title
- The difference between the two ways of thread implementation - simple summary
- Common current limiting methods
- iOS面试准备 - ios篇
- Use openmap and ArcGIS to draw maps and transportation networks of any region, and convert OMS data into SHP format
- JDBC statement + resultset introduction
- IOS interview preparation - Online
猜你喜欢

How does excel filter out the content you want? Excel table filtering content tutorial

Sguard64.exe ace guard client exe: frequent disk reading and writing, game jamming, and Solutions

SGuard64.exe ACE-Guard Client EXE:造成磁盘经常读写,游戏卡顿,及解决方案

使用近场探头和电流探头进行EMI干扰排查

iOS面试准备 - ios篇

How to set row height and column width in excel? The method of setting row height and column width in Excel

excel怎么设置行高和列宽?excel设置行高和列宽的方法
带你搞懂 Kubernetes 集群中几种常见的流量暴露方案

Stack and queue and priority queue (large heap and small heap) simulation implementation and explanation of imitation function

What are the core features of the digital transformation of state-owned construction enterprises?
随机推荐
C语言实现三子棋
What if excel is stuck and not saved? The solution of Excel not saved but stuck
Torch.nn.crossentropyloss() details
How does word view document modification traces? How word views document modification traces
Mysql:The user specified as a definer (‘root‘@‘%‘) does not exist 的解决办法
DataSourceClosedException: dataSource already closed at Mon Oct 25 16:55:48 CST 2021
GCC Basics
[untitled]
[wechat applet -- solve the alignment problem of the last line of display:flex. (discontinuous arrangement will be divided into two sides)]
How does WPS use smart fill to quickly fill data? WPS method of quickly filling data
Quick start JDBC
Exception - ...MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is ...
P5714 [deep foundation 3. Case 7] obesity
JDBC statement + resultset introduction
Stack and queue and priority queue (large heap and small heap) simulation implementation and explanation of imitation function
Implementation of img responsive pictures (including the usage of srcset attribute and sizes attribute, and detailed explanation of device pixel ratio)
Conv1d of torch
Take you to understand JS array
Common current limiting methods
leetcode 763. Partition Labels 划分字母区间(中等)