当前位置:网站首页>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
边栏推荐
- UE plays video in scene or UMG
- SSM integration, addition, deletion, modification and query
- Big silent event Google browser has no title
- Mapper agent development
- un7.28:redis客户端常用命令。
- Makefile+make Basics
- 五个关联分析,领略数据分析师一大重要必会处理技能
- 输入的查询SQL语句,是如何执行的?
- What are the core features of the digital transformation of state-owned construction enterprises?
- How is the entered query SQL statement executed?
猜你喜欢

Unity Metaverse(三)、Protobuf & Socket 实现多人在线

Data Lake: spark, a distributed open source processing engine

IOS interview preparation - Online

What if the office prompts that the system configuration cannot run?

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

Flink+iceberg environment construction and production problem handling

WPS insert hyperlink cannot be opened. What should I do if I prompt "unable to open the specified file"!

GCC Basics

Office提示系统配置无法运行怎么办?

SSM integration, addition, deletion, modification and query
随机推荐
ODOO开发教程之图表
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
【config】配置数组参数
Traffic flow prediction pit climbing record (I): traffic flow data set, original data
Simple user-defined authentication interface rules
AttributeError: ‘module‘ object has no attribute ‘create_connection‘
SparkSql批量插入或更新,保存数据到Mysql中
How to solve the problem of configuring the progress every time Office2010 is opened?
Deadlock to be resolved
Quick start JDBC
[wechat applet -- solve the alignment problem of the last line of display:flex. (discontinuous arrangement will be divided into two sides)]
[untitled]
Academic | [latex] super detailed texlive2022+tex studio download installation configuration
def fasterrcnn_resnet50_fpn()实例测试
office2010每次打开都要配置进度怎么解决?
Download addresses of various versions of MySQL and multi version coexistence installation
def fasterrcnn_ resnet50_ FPN () instance test
Flink+iceberg environment construction and production problem handling
iOS面试准备 - ios篇
P5714 [deep foundation 3. Case 7] obesity