js ... 使用

arr1 = [1,3,5,7,9]
arr2 = [2,4,6,8,10]

console.log(...arr1) // 展开数组
let arr3 = [...arr1, ...arr2] // 连接数组


传参
function sum(...number){
     return numbers.reduce((preValue, currentValue)=>{
     return preValue + currentValue
})   
}
sum(1,2,3,4,5,6)
复制对象
let a = {"name": "刘勇", "age": 18}

b = {...a} 深拷贝
c = a 浅拷贝
复制同时修改
d = {...a, "name": "老刘"}

 

posted @ 2021-01-15 19:37  ShanCe-刘勇  阅读(70)  评论(0编辑  收藏  举报