https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/find
Array.filter와 비슷하게 조건에 맞는 배열을 새로운배열로 리턴하지만
Array.find는 첫번째 요소만을 반환한다.
const array1 = [5, 12, 8, 130, 44];
const found = array1.filter(element => element > 10);
console.log(found); //[12, 130, 44]
const found2 = array1.find(element => element > 10);
console.log(found2); //12
'NOTE' 카테고리의 다른 글
react-helmet (0) | 2023.02.25 |
---|---|
기존 CRA프로젝트에 typescript 템플릿 추가하기 (0) | 2023.02.22 |
Swiper.js slidesPerGroup 슬라이드 여러장씩 이동시키기 (0) | 2023.02.03 |
a태그 이미지 다운로드 구현 (0) | 2022.03.20 |
:not 선택자는 익스 지원하지 않는다. (0) | 2021.09.29 |