This is a simplified version of the problem =>
const z = [
[1, 2, 3, 4, 5]
];
console.log(z);
z[0].splice(1, 1);
console.log(z);
Both Console logs output : Array [ (5) […] ] 0: Array(4) [ 1, 3, 4, … ] length: 1
How is splice affecting the first console log?
I was making an algorithm then I noticed that even before calling the splicing function my original array which had thousands of items was getting affected meaning that the "History" or "Log" array that I was trying to form always had the same spliced version of the array that i later on tried splicing.