当前位置:网站首页>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]
边栏推荐
- OPENSQL快速学习
- EMD empirical mode decomposition
- Remote desktop connection error
- Casbin入门
- (2022 Hangdian multi school III) 1002 boss rush (pressure dp+ dichotomy)
- EMD 经验模态分解
- Division of data link layer, protocols used in data link layer and detailed introduction
- Process tracking of ribbon principle
- CUB_ Visualization of key points in 200 bird dataset
- Functions and comparison of repeaters, hubs, bridges, switches and routers
猜你喜欢
Deep understanding of Base64 underlying principles
(codeforce547)C-Mike and Foam(质因子+容斥原理)
The digitalization of the consumer industry is upgraded to "rigid demand", and weiit's new retail SaaS empowers enterprises!
Violence recursion to dynamic programming 01 (robot movement)
CUB_200鸟类数据集关键点可视化
大厂们终于无法忍受“加一秒”了,微软谷歌Meta等公司提议废除闰秒
数字孪生实际应用案例-智慧能源篇
深入C语言(3)—— C的输入输出流
VISO fast rendering convolution block
Excel splicing database statement
随机推荐
Simple use of eventbus
Several cases of word wrapping in div
Kotlin companion object vs global function
(2022 Hangdian multi school III) 1011 link is as bear (thinking + linear basis)
How do programmers use code to completely end those things in the system?
路西法98-生活记录ing
Microcomputer principle and interface technology
Anaconda offline installation environment
Sunflower senior product director technology sharing: "how to apply national remote control" in AD domain environment
Cannot paste multiple pictures at once
数字孪生实际应用案例-智慧能源篇
Realize multi-level linkage through recursion
《陌路曾相逢》夏陌沈疏晏_夏陌沈疏晏最新章节
一文学透MySQL表的创建和约束
Deep into C language (1) -- operators and expressions
What you see and think in Microsoft
Division of data link layer, protocols used in data link layer and detailed introduction
(codeforce547) c-mike and foam
With more than 5 years of work experience and a salary of 15K, would you accept it if you were me?
安装抓包证书