Array.prototype.concat()

손연주·2021년 6월 17일
0
const a = [1,2,3];
a.concat([4,5,6]);
console.log(a) // [1,2,3]

concat은 immutable하기 때문에 concat한 값을 변수에 담아줘야 한다.

const b = a.concat([4,5,6])
console.log(b) // [1,2,3,4,5,6]
profile
할 수 있다는 생각이 정말 나를 할 수 있게 만들어준다.

2개의 댓글

comment-user-thumbnail
2022년 3월 30일

혹시 a를 const로 선언해서 immutable 한 건 아닐까요??

1개의 답글