Array 기초 개념 생략
forEach > Callback 함수를 받아온다.
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
Calls a defined callback function on each element of an array, and returns an array that contains the results.
Callback 함수를 선언하여 각자 실행할 수 있다
example)
frutirs.forEach(funtion(fruit, index, array) { console.log(fruit, index, array) } // 보통은 Array를 받아오진 않음으로 생략한다.
<- 이름이 없는 함수(anonymous function)은 Arrow function으로 사용 ->
frutirs.forEach((fruit, index) => console.log(fruit, index))
Array 추가 삭제 기초 생략
push / pop
unshift / shift - array control 특성상 애는 겁나 느림
splice(index, cnt) > index 부터 cnt까지 삭제