Written by
java-style
on
on
Array.prototype.concat()
Array.prototype.concat()
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
concat()은 일반적으로 사용되는 것 처럼 두개의 배열을 추가하는 하여 새 배열을 반환한다.
주의해야할 점은 concat()으로 병합시 배열내의 아이템의 type과 관련없이 단순히 추가하기만 한다는 것이다.
const array1 = ['1', '2', '3']; const array2 = [1, 2, 3]; const array3 = [{ name : "1" }]; const array4 = array1.concat(array2).concat(array3); console.log(array4); //Array ["1", "2", "3", 1, 2, 3, Object { name: "1" }]
숫자, 문자, Object와 같은 type과 상관없이 단순히 추가하기만 한다.
from http://leedohyun1985.tistory.com/92 by ccl(A) rewrite - 2021-11-11 18:27:09