When working on legacy projects it may be tempting to go around changing
const myCopy = arr.slice();
with:
const myCopy = [...arr];
but... DON'T DO IT!
It's not exactly the same.
const arr = [1,2,3];
arr[10] = 11; // (why would anyone do this is beyond me)
arr.forEach((n,i) => console.log(i,n))
// 0 1
// 1 2
// 2 3
// 10 11
arr.slice().forEach((n,i) => console.log(i,n))
// 0 1
// 1 2
// 2 3
// 10 11
[...arr].forEach((n,i) => console.log(i,n))
// 0 1
// 1 2
// 2 3
// 3 undefined
// 4 undefined
// 5 undefined
// 6 undefined
// 7 undefined
// 8 undefined
// 9 undefined
// 10 11