lodash
lodash?
javascript의 인기있는 라이브러리 중 하나로 보통 array, collection, date 등 데이터의 필수적인 구조를 쉽게 다룰 수 있게끔 하는 데에 사용된다._.(변수)
lodash wrapper로 변수를 감싸게 되면서 해당 편수에 대한 chaining을 시작
브라우저에서 지원하지 않는 성능이 보장되어있는 다양한 메소드를 가지고 있으며 퍼포먼스 측면에서 native보다 더 나은 성능을 가지며 npm이나 기타 패키지 매니저를 통해 쉽게 이용할 수 있다.
lodash method
array
findIndex()
_.findindex(array, [predicatie=.indentity],[thisArg])
index number 출력
flatten()
_.flatten(arraym[isDeep])
다차원 배열 내의 요소를 출력하는데 편리
remove()
.remove(array, [predicate=.identity], [thisArg])
제거된 array
배열 내의 조건에 맞는 요소들을 제거한 후 반환
every()
.every(collection, [predicate=.identity], [thisArg])
boolean 값 출력
find()
.find(collection, [predicate=.identity], [thisArg])
조건을 만족하는 컬렉션에서의 첫번째 요소를 찾는 메소드
filter()
.filter(collection, [predicate=.identity], [thisArg])
특정 조건을 만족하는 모든 요소를 추출하는 메소드
map()
.map(collection, [iteratee=.identity], [thisArg])
계산 결과 배열함수를 실행하고 그 결과를 배열로 반환
key값을 입력할 경우 해당 key값들만 간추려서 반환
forEach()
.forEach(collection, [iteratee=.identity], [thisArg])
배열의 값마다 함수를 실행
includes()
_.includes(collection, target, [fromIndex=0])
해당 collection에 target값이 있는지 판별
reduce()
.reduce(collection, [iteratee=.identity], [accumulator], [thisArg])
첫번째 인자에 대해 배열 내부의 값을 통해 콜백함수를 실행시킨 후 결과값을 반환