当前位置:网站首页>Es7/es9 -- new features and regularities
Es7/es9 -- new features and regularities
2022-06-25 23:03:00 【Climbing procedural ape】
ES7 New characteristics
Check whether the array contains an element includes 2**10 2 Of 10 Power
let array = [' A dream of red mansions ',' Journey to the west ',' The romance of The Three Kingdoms ',' Water margin ']
console.log(array.includes(' A dream of red mansions ')) // true
console.log(array.indexOf(' A dream of red mansions ')) // 0
console.log(2**10) // 1024 2 Of 10 Power ES9 Regular extension
(1) Regular grouping
As shown in the figure below , You can see the obvious regular grouping , And you can rename the matching value , Use attributes to get , When regular changes are prevented , The problem of digital position change
let str = '<a href="http://www.atguigu.com"> Silicon Valley </a>'
console.log(str)
const REG = /<a href="(?<url>.*)">(?<text>.*)<\/a>/ // Single quotation marks are not allowed here ,?<name> Is to rename the matched value
let result = REG.exec(str)
console.log(result)
console.log(result.groups.url)
(2) Reverse and forward assertions
Adding conditions , You can judge what is ahead or what is behind , Prevent matching to multiple

(3)dotAll
characteristic :. It's metacharacter , Any single character other than the newline character ,ES9 Added /s Can match any character , Add one at the end of the regular /s that will do
ES10 -- Object extension methods
Objects and Map Interchangeability of

ES10 -- A string of trimStart() And trimEnd()
let str = ` ilove you
and you `;
console.log(str.trimStart()) // Remove the initial blank
console.log(str.trimEnd()) // Remove the blanks at the end ES10 -- flat And flatMap
flat You can convert multidimensional arrays into one-dimensional arrays , The number inside is the depth of conversion

ES11 -- Private property
Use # Mark the private attribute , Private properties can be manipulated inside a class , It is not allowed outside the class

ES11 -- String Of mathAll Match all
for (let v for result){
// To extract in bulk
}
ES11 -- Optional chain operator ?.
config&&config.db&&config.db.host, First judge config Whether there is , And then determine config Medium db Whether there is , And then I got it host, I could just write it as config?.db?.host
ES11 -- dynamic import
Import again when using , Load faster
btn.onclick = function () {
import('./m1.js').then(module => {
module.hello();
})
}ES11 -- BigInt type Big integer , Add a after the number n that will do
Larger number operations , It supports integers of any length , Cannot operate with ordinary values , The result of the operation is the same BigInt
let n = 521n; let m = BigInt(521)
ES11 -- Absolute global object gloalThis, Point to windows object
边栏推荐
- 如何用jmeter做接口测试
- 2022-2028 global horizontal reciprocating compressor industry research and trend analysis report
- How to disable the optical drive
- Fastjson deserialization randomness failed
- Talk about adapter mode
- The Ping class of unity uses
- 【EOSIO】EOS/WAX签名错误 is_canonical( c ): signature is not canonical 问题
- 2022-2028 global extrusion coating and lamination production line industry research and trend analysis report
- Raspberry PI (bullseye) replacement method of Alibaba cloud source
- Global and Chinese flame retardant ABS industry development trend and market demand analysis report 2022 ~ 2028
猜你喜欢

【EOSIO】EOS/WAX签名错误 is_canonical( c ): signature is not canonical 问题

Multi modal data can also be Mae? Berkeley & Google proposed m3ae to conduct Mae on image and text data! The optimal masking rate can reach 75%, significantly higher than 15% of Bert

ES6学习-- LET

2022-2028 global horizontal reciprocating compressor industry research and trend analysis report

Use apiccloud AVM multi terminal component to quickly realize the search function in the app

记|一次exists关键字的学习记录

Use of local stack in flask

Fastjson deserialization randomness failed

Unity的Ping類使用

2022-2028 global transmission type photoelectric circuit breaker industry research and trend analysis report
随机推荐
Obsidian basic tutorial
ES6学习-- LET
Huawei cloud SMS has tested that many mobile phones prompt frequent sending
Use apiccloud AVM multi terminal component to quickly realize the search function in the app
String deformation (string case switching and realization)
27 Chinese scholars including Yaoban and chendanqi from Tsinghua won the awards, and the list of winners of Sloan award in 2022 was issued
Unity technical manual - life cycle rotation rotationoverlifetime- speed rotation rotationbyspeed- and external forces
Reasons why MySQL cannot be connected externally after installing MySQL database on ECs and Solutions
等价类,边界值,场景法的使用方法和运用场景
Dio encapsulated by the flutter network request (cookie management, adding interceptors, downloading files, exception handling, canceling requests, etc.)
Lecture 14 of the Blue Bridge Cup -- number theory [example]
Analysis report on market business model and development direction of China mobile operation industry from 2022 to 2028
2022-2028 global variable frequency compressor technology industry research and trend analysis report
2022年中职组网络安全新赛题
ES6-- 集合
Unity的Ping类使用
How to design a complex business system? From the understanding of domain design, cloud native, micro service, and middle platform
NRM source switching tool
Trillions of hot money smashed into the space economy. Is it really a good business?
Unity技术手册 - 粒子发射和生命周期内速度子模块