当前位置:网站首页>ES6 synchronous asynchronous execution and block level scope
ES6 synchronous asynchronous execution and block level scope
2022-06-30 01:23:00 【Madrid Tianxin】
const promise = new Promise((resolve,reject)=>{
console.log(1);
resolve();
console.log(2);
})
promise.then(()=>{
console.log(3);
})
console.log(4);structure => Constructors execute synchronously ,.then() Asynchronous execution .
So the output 1243~
console.log(a);//undefined
var a = 1;
If variables are overridden, use var Will be covered normally , Use let Error will be reported when overwriting
var There is no block-level scope , To be rude is to say that the apricots will come out of the wall . It still works normally when used outside the module .
But instead let Just report a mistake .
const Once the variable value is declared, it cannot be changed again -- Will report a mistake , Assignment must be made. - Otherwise an error
let Once a variable is declared, it can be changed , And become the changed value .
The following code can do without introducing other variables , Do not use addition and subtraction to make a And b The values of are swapped
let a = 1;
let b = 2;
[a,b]=[b,a]
console.log(a,b);When outputting again a The value is 2,b The value is 1 了 .
I wish you all a happy Lantern Festival !!!
边栏推荐
- Stimulus reports reporting tool, stimulus creates and builds reports
- Online text digit recognition list summation tool
- How to unify the use of package manager in a project?
- Internal class usage scenarios, syntax and principle explanations
- Kwai reached out to the "supply side" to find the "source" of live broadcast e-commerce?
- Taguchi experimental method
- Vl6180x distance and light sensor hands-on experience
- Clean, talk, bring children, and get rid of the label of "artificial mental retardation" for the sweeper
- Sentinel source code analysis Part 7 - sentinel adapter module - Summary
- How does webapi relate to the database of MS SQL?
猜你喜欢

Ansible ad-hoc temporary command

ctfshow 大赛原题 680-695

城市规划馆在设计制作上需要注意什么

Pytroch Learning Notes 6: NN network layer convolution layer
![[deep learning compilation] operator compilation IR conversion](/img/10/bdcabde772e65eebc93f870f597524.png)
[deep learning compilation] operator compilation IR conversion

我,33岁,字节跳动测试开发,揭开北京“测试岗”的真实收入

Quality management of functional modules of MES management system

How to refuse the useless final review? Ape tutoring: it is important to find a suitable review method

Mechanical --nx2007 (UG) -- gap analysis (interference inspection)

Analysis of IM instant messaging development technology on modern web
随机推荐
浅析现代Web端im即时通讯开发技术
【Proteus仿真】8位端口检测8独立按键
Varnish 基础概览7
Online text digit recognition list summation tool
英伟达Jetson Nano的初步了解
c语言期末不挂科(上)
81. 搜索旋转排序数组 II
快手伸手“供给侧”,找到直播电商的“源头活水”?
Reading is the cheapest noble
画画水族馆的应用特色及功能
ctfshow 大赛原题 680-695
Quality management of functional modules of MES management system
传统微服务框架如何无缝过渡到服务网格 ASM
Solution to webkitformboundaryk in post request
Mechanical --nx2007 (UG) -- gap analysis (interference inspection)
挖财的课程靠谱吗,让开户安全吗?
The listing of Symantec electronic sprint technology innovation board: it plans to raise 623million yuan, with a total of 64 patent applications
【推荐系统】基于用户的协同过滤简明原理与代码实现
Seata and the three platforms are working together in the summer of programming. Millions of bonuses are waiting for you
Netease cloud music beta music social app "mus" matches friends of the same frequency through music