Values & References2 / 18
Up next

Copy an array

// [...arr] and slice() make independent shallow copies
const original = [1, 2, 3];
const copy = [...original];
copy.push(4);
console.log(original, copy);
What you're solving

spread and slice make shallow copies