So I tried a simple example:
const original = [
{id: 0, color: "red"},
{id: 1, color: "blue"}
]
const copy = [...original]
copy[0] = {id:2, color:"red"}
copy[1].id = 2
console.log(original)
console.log(copy)
Results I am getting are confusing:
Array [Object { id: 0, color: "red" }, Object { id: 2, color: "blue" }]
Array [Object { id: 2, color: "red" }, Object { id: 2, color: "blue" }]
When I change the entire object, the change only happens in the copy array.
So why did copy[1].id = 2 actually also changed the original array and not only a key in the copy array??