Currently, I am working with an Array and need to modify the last item by pushing it back. Below is a simplified version of the code:
var array = [
[ [0,1,2], [3,4,5] ]
];
//other stuff...
var add = array[0].slice(); //creating a clone of the array (not functioning as expected)
add[0][0] = 10;
array.push(add);
console.log(array);
Here is the resulting output:
Upon inspection, both the first and second items in the array have their first element changed to 10
. How do I go about resolving this issue? The array has already been cloned.