当前位置:网站首页>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 .
边栏推荐
- [C language] address book - dynamic and static implementation
- Plasticscm enterprise crack
- ABP vNext microservice architecture detailed tutorial - distributed permission framework (Part 2)
- Analysis of glibc strlen implementation mode
- Clickpaas low code platform
- Uni app change the default component style
- WGS84 coordinate system, web Mercator, gcj02 coordinate system, bd09 coordinate system - brief introduction to common coordinate systems
- Why is there a reincarnation of 60 years instead of 120 years in the tiangan dizhi chronology
- 陇原战“疫“2021网络安全大赛 Web EasyJaba
- UE4 DMX和grandMA2 onPC 3.1.2.5的操作流程
猜你喜欢
C language course setting: cinema ticket selling management system
UI automation test farewell to manual download of browser driver
面试字节,过关斩将直接干到 3 面,结果找了个架构师来吊打我?
Installation of postman and postman interceptor
An elegant program for Euclid‘s algorithm
Test d'automatisation de l'interface utilisateur télécharger manuellement le pilote du navigateur à partir de maintenant
MindFusion. Virtual Keyboard for WPF
Differences among 10 addressing modes
About the recent experience of writing questions
快手、抖音、视频号交战内容付费
随机推荐
DMX parameter exploration of grandma2 onpc 3.1.2.5
Differences among 10 addressing modes
Redis之Jedis如何使用
Uni app common functions /api
[software reverse analysis tool] disassembly and decompilation tool
我就一写代码的,王总整天和我谈格局...
EasyCVR更改录像存储路径,不生成录像文件如何解决?
Behavior perception system
[an Xun cup 2019] not file upload
[数组]566. 重塑矩阵-简单
已解决(sqlalchemy+pandas.read_sql)AttributeError: ‘Engine‘ object has no attribute ‘execution_options‘
Enterprise level: spire Office for . NET:Platinum|7.7. x
[understand series after reading] 6000 words teach you to realize interface automation from 0 to 1
在线文本行固定长度填充工具
This article takes you to understand the relationship between the past and present of Bi and the digital transformation of enterprises
为什么百度、阿里这些大厂宁愿花25K招聘应届生,也不愿涨薪5K留住老员工?
陇原战“疫“2021网络安全大赛 Web EasyJaba
Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘
线上故障突突突?如何紧急诊断、排查与恢复
Threejs realizes sky box, panoramic scene, ground grass