What's the most optimized way to copy and duplicate an array into a new one, so arr1 = [1,2] becomes arr2 = [1,2,1,2]?
I can do this:
for(let a of arr1){
arr2.push(a)
}
for(let a of arr1){
arr2.push(a)
}
Is there a more optimized way to do it with a more efficient time complexity?