var arr = [ ['hello', 'and', 'hi'], [2,3,4] ],
arr2 = arr.slice();
arr2[1].push(44);
arr[0] = "new value";
console.log(arr, arr2);
//["new value", [2, 3, 4, 44]]
//[["hello", "and", "hi"], [2, 3, 4, 44]]
Isn't arr2 = arr.slice()
supposed to create a new copy of arr
? Therefore, arr2[1].push(44)
won't effect the original arr
Can anyone tell me why the console logged arr has number 44 in its second element?