Returns the first found value that matches predicate or undefined.
predicate
Use some if you don't care about the value, just whether it appears. Use filter to get all value(s) that match predicate.
const overThirty = find(people, person => person.age > 30); Copy
const overThirty = find(people, person => person.age > 30);
Map to search
Function that returns true for a matching value
Found value or undefined
Returns the first found value that matches
predicate
or undefined.Use some if you don't care about the value, just whether it appears. Use filter to get all value(s) that match
predicate
.Example: First person over thirty