当前位置:网站首页>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]
边栏推荐
- Use of leak scanning (vulnerability scanning) tool burpsuite or burp Suite (with installation and installation package download of burpsuite+1.7.26)
- Simple use of eventbus
- How fast does it take to implement a super simple programming language?
- How to understand "page storage management scheme"
- Division of data link layer, protocols used in data link layer and detailed introduction
- Solve the delay in opening the console of Google browser
- 深入C语言(4)——switch的定义与使用
- Typescript from getting started to mastering (XXII) namespace namespace (I)
- 2. Variables and scope
- Realize multi-level linkage through recursion
猜你喜欢

Multi level wavelet CNN for image restoration

CUB_ Visualization of key points in 200 bird dataset

Deep into C language (3) -- input and output stream of C

tron OUT_ OF_ ENERGY

Alibaba Font Icon Library Usage and update methods

Rdkit I: using rdkit to screen the structural characteristics of chemical small molecules

Process tracking of ribbon principle

Typescript from getting started to mastering (XX) function generics

Excel splicing database statement

for_each用法示例
随机推荐
In depth C language (4) -- definition and use of switch
RHCE的at,crontab的基本操作,chrony服务和对称加密和非对称加密
Excel拼接数据库语句
路西法98-生活记录ing
for_ Example of each usage
MOS管 —— 快速复苏应用笔记(贰)[参数与应用]
Code speed optimization
力扣每日一题-第44天-205. 同构字符串
3.解决Pycharm报错Unresolved reference ‘selenium‘ Unresolved reference ‘webdriver‘
Some notes on uniapp
The difference between /g /m /i of JS regular expressions
Violence recursion to dynamic programming 01 (robot movement)
How do programmers use code to completely end those things in the system?
(newcoder 15079)无关(容斥原理)
In depth C language (2) -- definition and use of structure
JS regular expression finds the number of times a character (string) appears (one line of code)
深入C语言(2)——结构的定义与使用
Rdkit: introduce smiles code, smart code and Morgan fingerprint (ECFP)
Uni app internationalization
Sleuth+zipkin to track distributed service links