当前位置:网站首页>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 .
边栏推荐
- ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
- Open graph protocol
- Threejs Internet of things, 3D visualization of factory
- laravel8 导出Excle文件
- DFS and BFS concepts of trees and graphs
- How to solve the problem that easycvr changes the recording storage path and does not generate recording files?
- Technical tutorial: how to use easydss to push live streaming to qiniu cloud?
- 已解决(sqlalchemy+pandas.read_sql)AttributeError: ‘Engine‘ object has no attribute ‘execution_options‘
- A应用唤醒B应该快速方法
- 测试开发是什么?为什么现在那么多公司都要招聘测试开发?
猜你喜欢

error Couldn‘t find a package. JSON file in "your path“

Redis source code analysis: redis cluster

Three level linkage demo of uniapp uview u-picker components

北京程序员的真实一天!!!!!

Containerd series - what is containerd?

在线SQL转Excel(xls/xlsx)工具

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

灵魂三问:什么是接口测试,接口测试怎么玩,接口自动化测试怎么玩?

Threejs implements labels and displays labels with custom styles

Differences among 10 addressing modes
随机推荐
Deep learning - LSTM Foundation
北京程序员的真实一天!!!!!
10种寻址方式之间的区别
Pyqt pyside custom telescopic menu bar sharing (including tutorial)
Summary of scene design
[wp][introduction] brush weak type questions
Behavior perception system
What is test development? Why do so many companies hire test developers now?
[brush questions] BFS topic selection
企业级:Spire.Office for .NET:Platinum|7.7.x
JWT vulnerability recurrence
Alibaba cloud ECS uses cloudfs4oss to mount OSS
Get to know MySQL connection query for the first time
Laravel8 export excel file
How does the applet solve the rendering layer network layer error?
grandMA2 onPC 3.1.2.5的DMX参数摸索
NEW:Devart dotConnect ADO.NET
Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘
快手、抖音、视频号交战内容付费
已解决(sqlalchemy+pandas.read_sql)AttributeError: ‘Engine‘ object has no attribute ‘execution_options‘