본문 바로가기

공부/JS

push & concat

배열에 데이터를 추가하는 방법

push

  • 원본 배열의 값이 변경된다.

concat

  • 원본은 그대로지만 원본을 변경한 새로운 배열이 반환된다.
  • 불변성(immutable) 를 유지할 수 있다.

 

push 보다는 concat 을 사용하자!!

 

불변성을 지키기 위한 방법

 

Immutable.js

Immutable collections for JavaScript Read the docs and eat your vegetables. Docs are automatically generated from README.md and immutable.d.ts. Please contribute! Also, don't miss the wiki which contains articles on additional specific topics. Can't find s

immutable-js.com

'공부 > JS' 카테고리의 다른 글

[자바스크립트] 내장객체  (0) 2019.04.29