当前位置:网站首页>Extended operator of new features in ES6
Extended operator of new features in ES6
2022-07-29 03:45:00 【Haha, APE】
… The extension operator can convert an array into a comma separated sequence of parameters
Extension operator (spread) Also three points (…). It's like rest Inverse operation of parameter , Convert an array to a comma separated sequence of parameters , Unpack the array
Basic use
Declare an array
const beautifulGirl = [" Xiao Liu "," Xiao Ming "," Xiaolingzi "]
function myGirl(){
console.log(arguments);
}
myGirl(...beautifulGirl)
// Print the results :" Xiao Liu "," Xiao Ming "," Xiaolingzi "
application :
Merging of arrays
const beautifulGirl = [" Xiao Liu "," Xiao Ming "," Xiaolingzi "]
const cuteBoy = [" Xiao Zhang "," ha-ha "," Fat man "]
The traditional way of merging concat
const lovers = beautifulGirl.concat(cuteBoy)
console.log(lovers);
// Print the results :[' Xiao Liu ', ' Xiao Ming ', ' Xiaolingzi ', ' Xiao Zhang ', ' ha-ha ', ' Fat man ']
ES6 Expand operator merge :
const lovers = [...beautifulGirl,...cuteBoy]
console.log(lovers);
// [' Xiao Liu ', ' Xiao Ming ', ' Xiaolingzi ', ' Xiao Zhang ', ' ha-ha ', ' Fat man ']
Clone of array :
const xiaoLiu = [" Xiao Liu "," Xiaolingzi "," Xiao Ming "]
const Girl = [...xiaoLiu]
console.log(Girl);
// Print the results :[' Xiao Liu ', ' Xiaolingzi ', ' Xiao Ming ']
Convert a pseudo array to a real array
const divs = document.querySelectorAll("div")
const divArr = [...divs]
console.log(divArr);
// [div]
边栏推荐
- With more than 5 years of work experience and a salary of 15K, would you accept it if you were me?
- Connect with third-party QQ login
- "Strangers once met" Summer Street Shen Shuyan_ Xia Mo Shen Shuyan's latest chapter
- Why do many programmers hate pair programming?
- Uni app internationalization
- Various minor problems of jupyter notebook, configuration environment, code completion, remote connection, etc
- (codeforce547) c-mike and foam
- CUB_200鸟类数据集关键点可视化
- 华为天才少年稚晖君做了一把模块化机械键盘,引起极客圈地震,网友:这才是真正的客制化...
- (nowcoder22529C)dinner(容斥原理+排列组合)
猜你喜欢

Why is continuous integration and deployment important in development?

for_ Example of each usage

Getting started with caspin

Violence recursion to dynamic programming 01 (robot movement)

Practical application cases of digital Twins - smart energy

Ribbon principle analysis namedcontextfactory

(codeforce547)C-Mike and Foam(质因子+容斥原理)

Vs code must know and know 20 shortcut keys!

Alibaba Font Icon Library Usage and update methods

@Configuration (proxybeanmethods = false) what's the use of setting this to false
随机推荐
Code speed optimization
Typescript from introduction to proficiency (XXIV) using import syntax
(2022 Hangdian multi school III) 1002 boss rush (pressure dp+ dichotomy)
CUB_ Visualization of key points in 200 bird dataset
Why do many programmers hate pair programming?
The list is not updated in real time when JS V-for data changes
Practical application cases of digital Twins - smart energy
(2022 Hangdian multi school III) 1011 link is as bear (thinking + linear basis)
新零售O2O 电商模式解析
Violence recursion to dynamic programming 01 (robot movement)
关于ALV格式控制部分的写法
How fast does it take to implement a super simple programming language?
Sleuth+zipkin to track distributed service links
Since 2019, you must have stopped using this marketing strategy
Data too long for column 'xxx' at row 1 solution
(codeforce547) c-mike and foam
@Configuration (proxybeanmethods = false) what's the use of setting this to false
1985-2020(8个版次)全球地表覆盖下载与介绍
Casbin入门
(codeforce547)C-Mike and Foam(质因子+容斥原理)