当前位置:网站首页>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 .
边栏推荐
- kubernetes集群之调度系统
- Laravel8 export excel file
- 根据入栈顺序判断出栈顺序是否合理
- [software reverse analysis tool] disassembly and decompilation tool
- BDF application - topology sequence
- Technical tutorial: how to use easydss to push live streaming to qiniu cloud?
- Use threejs to create geometry, dynamically add geometry, delete geometry, and add coordinate axes
- speed or tempo in classical music
- The new project Galaxy token just announced by coinlist is gal
- 在线SQL转Excel(xls/xlsx)工具
猜你喜欢
[software reverse analysis tool] disassembly and decompilation tool
Is "golden nine and silver ten" the best time to find a job? Not necessarily
花了2晚,拿到了吴恩达@斯坦福大学的机器学习课程证书
NEW:Devart dotConnect ADO. NET
JWT vulnerability recurrence
函数基础学习02
面试字节,过关斩将直接干到 3 面,结果找了个架构师来吊打我?
Use of vscode software
NEW:Devart dotConnect ADO.NET
EasyCVR平台出现WebRTC协议视频播放不了是什么原因?
随机推荐
长度为n的入栈顺序的可能出栈顺序种数
Threejs clicks the scene object to obtain object information, and threejs uses raycaster to pick up object information
What is the reason why the webrtc protocol video cannot be played on the easycvr platform?
The order of LDS links
[数组]566. 重塑矩阵-简单
provide/inject
Timing manager based on C #
The new project Galaxy token just announced by coinlist is gal
[wp]bmzclub writeup of several questions
error Couldn‘t find a package. JSON file in "your path“
Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
Laravel8 export excel file
“金九银十”是找工作的最佳时期吗?那倒未必
灵魂三问:什么是接口测试,接口测试怎么玩,接口自动化测试怎么玩?
Excuse me, my request is a condition update, but it is blocked in the buffer. In this case, can I only flush the cache every time?
在线SQL转Excel(xls/xlsx)工具
Threejs implements labels and displays labels with custom styles
JVM garbage collection
NEW:Devart dotConnect ADO. NET
DMX parameter exploration of grandma2 onpc 3.1.2.5