티스토리 뷰
반응형
1. helpermethod
자바스크립트에서 helpermethod인 some과 all에 대해 알아보자. 가장 기초적인 예시부터 다양한 예시를 적어보겠다. some과 all의 차이점을 인지하면서 보자.
2. some
리스트의 각 요소 중에 단 하나라도 만족하는 것이 있다면 True 없다면 False가 출력된다.
const arr = [10, 20, 30]
const isBiggerThan20 = arr.some(num => num > 20)
console.log(isBiggerThan20)
// true
3. every
리스트의 모든 요소가 조건을 만족하면 true, 아니라면 false를 리턴한다.
const arr = [10, 20, 30]
const allBiggerThan5 = arr.every(num => num > 5)
const allBiggerThan11 = arr.every(num => num > 11)
console.log(allBiggerThan5, allBiggerThan11)
// true false
반응형
'Web > JAVASCRIPT' 카테고리의 다른 글
| [nodejs error] UnhandledPromiseRejectionWarning: SequelizeAccessDeniedError: Access denied for user 'root'@'localhost' (using password: NO) (0) | 2021.11.15 |
|---|---|
| [nodejs / express] POST 안받아지는 문제 (0) | 2021.11.04 |
| Javascript_filter, find 기초 정리 (0) | 2020.12.20 |
| Javascript_forEach 기초 정리 (0) | 2020.12.19 |
| Javascript_map 기초 정리 (0) | 2020.12.18 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- DFS
- NextJS
- next.config.js
- Express
- pandas
- Deque
- JavaScript
- vuejs
- BFS
- react
- django
- Queue
- useState
- nextjs autoFocus
- error:0308010C:digital envelope routines::unsupported
- login
- logout
- typescript
- nodejs
- TensorFlow
- react autoFocus
- UserCreationForm
- 자연어처리
- 자료구조
- read_csv
- useHistory 안됨
- Python
- 클라우데라
- mongoDB
- Vue
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함
