Values & References18 / 18
Up next

Shallow copies share nesting

const grid = [[1, 2], [3, 4]];
// a spread copy shares the nested arrays
const shallow = [...grid];
shallow[0].push(99);
console.log(grid[0]);
What you're solving

inner objects are still shared