当前位置:网站首页>New features of ES6
New features of ES6
2022-07-26 23:41:00 【zpy66669】
Preface
Now in the mainstream front-end framework ,Vue.js etc. , Will be used ES6 New features
Still have java Basic learning is very simple
let and const
- let, prevent var The defined variable becomes a global variable




- const, Be similar to java Medium final keyword , Cannot be modified


String extension
- includes() Returns a Boolean value , Is the parameter string found
- startsWith() Returns a Boolean value , Whether the parameter string is at the head of the original string ( Whether or not to xxx start )
- endsWith() Returns a Boolean value , Whether the parameter string is at the end of the original string ( Whether it ends with xxx)
String template `` Number pad one left 
Structure expression
ES6 Allows you to extract values from arrays and objects according to certain patterns , And then assign values to variables , This is called deconstruction
An array of deconstruction

Object to deconstruct

Function optimization
Function parameter defaults

Arrow function


map
Receive a function , All elements in the original array are processed with this function and put into the new array to return

reduce
reduce()∶ Receive a function ( must ) And an initial value ( Optional ) This function takes two arguments ∶
- The first parameter is the last time reduce Results of processing
- The second parameter is the next element in the array to be processed
reduce() The elements in the array will be used from left to right with reduce Handle , And treat the result as next time reduce The first parameter of . If it's the first time , The first two elements are taken as calculation parameters , Or take the initial value specified by the user as the starting parameter
give an example

Extension operator
…, Convert an array to a comma separated sequence of parameters

Promise
the i Predicate Promise, It's simply a container , It holds an event that will end in the future ( This is usually an asynchronous operation ) Result . grammatically ,Promise It's an object , From it you can get messages for asynchronous operations .Promise Provide uniform API, Various asynchronous operations can be handled in the same way .
We can go through Promlse Constructor to create Promise object , And encapsulate the result of an asynchronous execution inside .

Set and Map data structure
Set
The essence is similar to array , The same elements will be ignored , and java Medium Set Set similar

Map
The essence is with Object Similar structures , Difference is that ,Object A mandatory provision ket It can only be a string , and Map Structural key It can be any object
- Object yes <String,object>
- Map yes <object,object>

class
and java almost , I don't feel like writing
Generator function *
- Generatar Letter is ES6 It provides an asynchronous comprehensive solution , Grammatical behavior is totally different from traditional function
- Generator Functions have two characteristics : One is function There is an asterisk between the command and the function name ; The second is the internal use of the function body yield I define different internal states
<script>
function * hello(){
yield "hello"
yield "niuma"
yield "xigua"
yield "qnm"
return "sl"
}
let h = hello()
console.log(h.next())
console.log(h.next())
console.log(h.next())
console.log(h.next())
console.log(h.next())
// Another way
for(let v for h){
console.log(v)
}
</script>

Transcoder
边栏推荐
- MySQL syntax uses detailed code version
- Distributed lock and its implementation
- 会议OA项目排座功能以及送审功能
- Positioning of soaring problems caused by online MySQL CPU
- 银河证券网上开户佣金,网上客户经理开户安全吗
- ES6新特性
- 【2016】【论文笔记】差频可调谐THz技术——
- Part II - C language improvement_ 8. File operation
- Bid farewell to wide tables and achieve a new generation of Bi with DQL
- About statefulwidget, you have to know the principle and main points!
猜你喜欢

Esmfold: a new breakthrough in protein structure prediction after alphafold2

研究阿尔茨海默病最经典的Nature论文涉嫌造假

Hcia-r & s self use notes (21) STP technical background, STP foundation and data package structure, STP election rules and cases

C语言数组

第二部分—C语言提高篇_7. 结构体

关于可穿戴式NFT你应该知道的一切!

Product principles of non-financial decentralized application
![[shader realizes shine effect _shader effect Chapter 3]](/img/ea/6c14f682e6157a96c1877d99c9f7d3.png)
[shader realizes shine effect _shader effect Chapter 3]

数据供应链的转型 协调一致走向成功的三大有效策略

Part II - C language improvement_ 9. Linked list
随机推荐
Part II - C language improvement_ 6. Multidimensional array
力扣155题,最小栈
企业数据治理面临的六大挑战!
MySQL 数据的导入
第二部分—C语言提高篇_10. 函数指针和回调函数
会议OA项目排座功能以及送审功能
Problems and solutions encountered in using nextline(), nextint() and next() in scanner
公有云安全性和合规性方面的考虑事项
[Luogu] p2341 popular cattle
Import of MySQL data
华测RTK采集的GPX数据如何带属性转出kml、shp进行后续的管理和分析
第二部分—C语言提高篇_11. 预处理
Kingbasees SQL language reference manual of Jincang database (3.1.1.14. scope type)
Re understand the life world and ourselves
Science | University of Washington uses AI and structural prediction to design new proteins
What are the use cases in the Internet of things industry in 2022?
ES6新特性
[MySQL] CentOS 7.9 installation and use mysql-5.7.39 binary version
Practical project: boost search engine
Pre research of data quality management tools Griffin vs deequ vs great expectations vs quality