var arr1 = ['a','b','c']; var arr2 = arr1; arr2.push('d'); //Now, arr1 = ['a','b','c','d']
I realized that
arr2 refers to the same array as
arr1, rather than a new, independent array. How can I copy the array to get two independent arrays?