728x90
✨ testing function의 결과로 나온 array 중 첫 번째 값(value)을 반환하는 build-in method
💻Example Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [5, 10, 15, 20, 25]; | |
const found = arr.find(element => element > 10); | |
const found2 = arr.find(element => element > 5); | |
console.log(found); | |
console.log(found2); |

🧨 DOM에서 원하는 node를 찾고자 할 때 유용하게 사용할 수 있다.

👉 자세한 내용은 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
Array.prototype.find()
The find() method returns the value of the first element in the provided array that satisfies the provided testing function.
developer.mozilla.org
'JavaScript > Built-in Method etc.' 카테고리의 다른 글
String.prototype.trim() (2) | 2020.08.10 |
---|---|
Array.prototype.splice() (2) | 2020.05.15 |
String.prototype.charAt() (0) | 2020.02.22 |
Set (Object) (0) | 2020.02.20 |
String.prototype.localeCompare() (0) | 2020.02.20 |