常用的几种数组深拷贝的方法

1.用剩余操作符 …

let arr = [1,2,3,4,5]
let newArr = [...arr]
newArr = newArr.shift()
console.log(arr) //     [1,2,3,4,5]
console.log(newArr) // [2,3,4,5]

2.用concat方法

let arr = [1,2,3,4,5]
let newArr = [].concat(arr)
newArr = newArr.shift()
console.log(arr) //     [1,2,3,4,5]
console.log(newArr) // [2,3,4,5]

3.用slice方法

let arr = [1,2,3,4,5]
let newArr = arr.slice()
newArr = newArr.shift()
console.log(arr) //     [1,2,3,4,5]
console.log(newArr) // [2,3,4,5]

4.用map遍历

let arr = [1,2,3,4,5]
let newArr = arr.map( (item)=> item )
newArr = newArr.shift()
console.log(arr) //     [1,2,3,4,5]
console.log(newArr) // [2,3,4,5]