[Javascript]배열에서 찾고 싶은 게 있을 때 (every, some, find, findIndex)
배열에 있는 요소 중 하나라도 해당 조건을 만족하는게 있는지 알고 싶을 때 some https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/some const array = [1, 2, 3, 4, 5]; const even = (val) => val % 2 === 0; console.log(array.some(even)); // true const found = (val) => val % 6 === 0; console.log(array.some(found)); // false 배열에 있는 모든 요소가 해당 조건을 만족하는지 알고 싶을 때 every https://developer.mozilla.org/ko/do..
Javascript
2022. 5. 12. 22:48