Iterates over elements of collection, returning the first element where predicate returns truthy value. The predicate is invoked with three arguments: (value, index|key, collection).
(value, index|key, collection)
let users = [ { 'user': 'barney', 'age': 36, 'active': true }, { 'user': 'fred', 'age': 40, 'active': false }, { 'user': 'pebbles', 'age': 1, 'active': true }]find(users, (o) => o.age < 40)// object for 'barney'// The shape iteratee shorthand.find(users, { 'age': 1, 'active': true })// object for 'pebbles'// The `property` iteratee shorthand.find(users, 'active')// object for 'barney'
The matched element, else undefined.
undefined
findLast
The collection to iterate over.
The function invoked per iteration.
Generated using TypeDoc
Iterates over elements of collection, returning the first element where predicate returns truthy value. The predicate is invoked with three arguments:
(value, index|key, collection)
.Example
Returns
The matched element, else
undefined
.See
findLast