JS 배열 및 객체
배열 vs. 객체
- 배열
1) 순서 정해져 있음
2) 반복문 형식1: for(let i=0;i<arr.length;i++)
3) 반복문 형식2: for(let element of array)
- 객체
1) 순서 정해져 있지 않음
2) 반복문 형식: for(let key in object)
3) dot notation (obj.key)
4) braket notation (obj['key'])
Immutable Method vs. Mutable Method
- Immutable(원본 변화 없음)
1) Slice
- arr2=arr1.slice(); arr1를 복사해서 arr2에 할당
- arr2=arr1.slice(3); arr1[3]부터 arr1[arr1.length]까지의 Element를 담은 배열을 arr2에 할당
- Mutable(원본 변화 있음)
1) Push, Unshift, Pop, Shift
! 배열과 객체는 앞으로 상업용 프로그래밍 시 매우 자주 사용될 것으로 보이므로 확실하게 익혀둬야 겠다.