You changed one array. Why did both change?
const original = [1, 2];
const copy = original;
copy.push(3);
console.log(original);
// [1, 2, 3] — wait, why?The name copy is misleading: assignment never created a second array. Both variables point to the same one. Pushing through either name changes that shared array.
Take it with you: Need a separate array? Use const copy = [...original]. That copies the outer array; nested objects would still be shared.

