Knowledgize

.find()

Returns the value of the first element in the array that satisfies the provided testing function.


Examples:

let numbers = [5, 12, 8, 130, 44]; let found = numbers.find(num => num > 10); console.log(found); // 12
let people = [{ name: 'Jack', age: 20 }, { name: 'Laura', age: 18 }]; let adult = people.find(person => person.age >= 18); console.log(adult); // { name: 'Jack', age: 20 }