08. 扩展运算符

2023-08-15 13:22:15发布
19
const nameList = ['tom', 'marry', 'jum'];
console.log(...nameList) // 输出 tom marry jum

// 作用1 合并数组
const a = [1, 2, 3]
const b = [4, 5]
const c = [...a, ...b]
console.log(c)

// 作用2 拷贝数组(浅拷贝)
const d = [1, 2, 3]
const f = [...d]
console.log(f)