当前位置:网站首页>Common features of ES6
Common features of ES6
2022-07-05 04:04:00 【The boat starts again】
1. Different variable declarations :const let and var
| const | let | var | |
| Scope | Yes | Yes | nothing |
| Whether it is a variable | Is a constant | Variable | Variable |
var No matter where the statement is , Will be considered declared at the top of the function ,
const Declared value is constant , The value of a constant cannot be changed after it is set , But if const What is declared is an object , Object contains values that can be modified . In an abstract sense, the address pointed to by the object does not change .
2. Template string
Basic string formatting , Embed the expression in the string for splicing ${} To define
before :"xxx"+name+"xxx"+age
Now? :`xxx${name}xxx${age}`
3. Arrow function
ES6 Middle arrow function is a short form of function , Wrap parameters in parentheses , Follow a => Next is the function body
The three most intuitive features of arrow function : Unwanted function Keyword to create a function , omitted return keyword , Inherits the current context this Point to ( namely this The direction of will not change )

details : When your function has only one parameter, you can omit the parentheses , When your function has and only has one expression, it can be omitted {} and return
4.Spread/Rest The operator ...
rest The parameter form is :... Variable name rest This is to solve the problem that the number of parameters passed in is not necessarily , Itself is an array , Array related methods can be used
Extension operator : like rest Inverse operation of parameter , Convert an array to use , The parameter sequence separated by is mostly used to merge arrays

5. Binary and octal literals
ES6 Support binary and 8 The literal amount of base
By adding... Before the number 0O perhaps 0o octal ( turn )0b or 0B Binary system ( turn )
6. Object and array deconstruction
{xxx,xxx,xxx}
7.for...of and for...in
for..of Used to traverse an iterator , Such as arrays
for...in Used to traverse properties in objects
8.ES6 modularization
Modularity mainly includes the following three uses :
Default export and default import export default import xxx from xxx
Export on demand and import on demand export xxx import{xxx,xxx} from xxx
Directly import and execute the code in the module import xxx
9.promise
In order to solve the problem of callback to hell ,ES6 Added in promise, It's a constructor , We can create promise Example const p = new promise(),new Coming out promise Instance object , Represents an asynchronous operation ,promise.propotype Contains a .then() Method , Use a callback function that specifies success and failure in advance .
边栏推荐
- 基于TCP的移动端IM即时通讯开发仍然需要心跳保活
- An elegant program for Euclid‘s algorithm
- EasyCVR更改录像存储路径,不生成录像文件如何解决?
- 小程序中实现文章的关注功能
- Threejs Internet of things, 3D visualization of factory
- Threejs loads the city obj model, loads the character gltf model, and tweetjs realizes the movement of characters according to the planned route
- MindFusion.Virtual Keyboard for WPF
- Redis之Jedis如何使用
- 在线SQL转Excel(xls/xlsx)工具
- 根据入栈顺序判断出栈顺序是否合理
猜你喜欢

Official announcement! The third cloud native programming challenge is officially launched!

Interview byte, pass the exam and directly work on three sides. As a result, I found an architect to hang me?

Threejs rendering obj+mtl model source code, 3D factory model

Plasticscm enterprise crack

Rust区块琏开发——签名加密与私钥公钥
![[wp][introduction] brush weak type questions](/img/d0/9eb3ade701057837d98e4a20082a10.png)
[wp][introduction] brush weak type questions

As soon as I write the code, President Wang talks with me about the pattern all day
![[brush questions] BFS topic selection](/img/24/7ec68ef60f94f7b366054824223709.png)
[brush questions] BFS topic selection

Interview summary: This is a comprehensive & detailed Android interview guide

JWT vulnerability recurrence
随机推荐
ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
请问一下我的请求是条件更新,但在buffer中就被拦截了,这种情况我只能每次去flush缓存么?
[array]566 Reshape the matrix - simple
error Couldn‘t find a package. JSON file in "your path“
Threejs rendering obj+mtl model source code, 3D factory model
provide/inject
postman和postman interceptor的安装
Plasticscm enterprise crack
[software reverse analysis tool] disassembly and decompilation tool
Threejs factory model 3DMAX model obj+mtl format, source file download
3. Package the bottom navigation tabbar
provide/inject
open graph协议
About the recent experience of writing questions
Laravel8 export excel file
An elegant program for Euclid‘s algorithm
在线SQL转Excel(xls/xlsx)工具
Deflocculant aminoiodotide eye drops
技术教程:如何利用EasyDSS将直播流推到七牛云?
What is test development? Why do so many companies hire test developers now?