ES6에서 등장한 배열 전개 연산(spread opeartor)은 배열의 모든 요소를 개별 요소로 변환한다.
const arr = [10, 20, 30, 40, 50];
console.log(...arr);
var arr = [10, 20, 30, 40, 50];
var copyArr = [];
for(var i=0; i < arr.length; i++) {
copyArr.push(arr[i]);
}
var arr = [10, 20, 30, 40, 50];
var copyArr = [];
arr.forEach(value=>copyArr.push(value));
const arr = [10, 20, 30, 40, 50];
const copyArr = JSON.parse(JSON.stringify(arr));
const arr = [10, 20, 30, 40, 50];
const copyArr = [...arr];
var arr1 = [10, 20, 30], arr2 = [100, 200];
var arr3 = [];
for(var i=0; i < arr1.length; i++){
arr3.push(arr1[i]);
}
for(var i=0; i < arr2.length; i++){
arr3.push(arr2[i]);
}
const arr1 = [10, 20, 30], arr2 = [100, 200];
const arr3 = arr1.concat(arr2);
const arr1 = [10, 20, 30], arr2 = [100, 200];
const arr3 = [...arr1, ...arr2];