250x250
Notice
Recent Posts
Recent Comments
- Today
- Total
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- TailwindCSS
- RDS
- clipBehavior
- async
- MYSQL
- mongodb
- Find
- single quote
- findByIdAndDelete
- jsonwebtoken
- https
- flutter
- moment
- AWS
- mongoose
- wil
- TypeScript
- css
- await
- JavaScript
- Node.js
- atlas
- Nodejs
- sequelize
- certbot
- Express
- EC2
- nginx
- double quote
- til
Link
Archives
기억 휘발 방지소
[JavaScript] find() 본문
728x90
반응형
find() 메서드는 주어진 판별 함수를 만족하는 첫 번째 요소의 값을 반환한다. 그런 요소가 없다면 undefined를 반환한다. (출처: MDN)
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const found = array.find((el) => el > 5);
console.log(found); // 6
객체들이 들어있는 배열에서도 다음과 같이 쓸 수 있다.
const array = [
{ name: "Kim", age: 23, hobby: "eat" },
{ name: "Park", age: 32, hobby: "drive" },
];
const found = array.find((el) => el.name === "Kim");
console.log(found); // { name: 'Kim', age: 23, hobby: 'eat' }
728x90
반응형
'Web > JavaScript' 카테고리의 다른 글
| [JavaScript] sort() (0) | 2021.10.02 |
|---|---|
| [JavaScript] includes() (0) | 2021.09.25 |
| [JavaScript] reduce() (0) | 2021.09.11 |
| [JavaScript] async/await (0) | 2021.09.05 |
| [JavaScript] Promise (0) | 2021.09.04 |