Returns the first matched element, else undefined
.
var users = [
{ 'user': 'barney', 'age': 36, 'active': true },
{ 'user': 'fred', 'age': 40, 'active': false },
{ 'user': 'pebbles', 'age': 1, 'active': true }
];
find(users, function(o) { return o.age < 40; });
// => object for 'barney'
// The `matches` iteratee shorthand.
find(users, { 'age': 1, 'active': true });
// => object for 'pebbles'
// The `matchesProperty` iteratee shorthand.
find(users, ['active', false]);
// => object for 'fred'
// The `property` iteratee shorthand.
find(users, 'active');
// => object for 'barney'
Iterates over elements of collection
, returning the first element
predicate
returns truthy for. The predicate is invoked with three
arguments: (value, index|key, collection).
Returns the first matched element, else undefined
.
var users = [
{ 'user': 'barney', 'age': 36, 'active': true },
{ 'user': 'fred', 'age': 40, 'active': false },
{ 'user': 'pebbles', 'age': 1, 'active': true }
];
find(users, function(o) { return o.age < 40; });
// => object for 'barney'
// The `matches` iteratee shorthand.
find(users, { 'age': 1, 'active': true });
// => object for 'pebbles'
// The `matchesProperty` iteratee shorthand.
find(users, ['active', false]);
// => object for 'fred'
// The `property` iteratee shorthand.
find(users, 'active');
// => object for 'barney'
Iterates over elements of collection
, returning the first element
predicate
returns truthy for. The predicate is invoked with three
arguments: (value, index|key, collection).
Returns the first matched element, else undefined
.
var users = [
{ 'user': 'barney', 'age': 36, 'active': true },
{ 'user': 'fred', 'age': 40, 'active': false },
{ 'user': 'pebbles', 'age': 1, 'active': true }
];
find(users, function(o) { return o.age < 40; });
// => object for 'barney'
// The `matches` iteratee shorthand.
find(users, { 'age': 1, 'active': true });
// => object for 'pebbles'
// The `matchesProperty` iteratee shorthand.
find(users, ['active', false]);
// => object for 'fred'
// The `property` iteratee shorthand.
find(users, 'active');
// => object for 'barney'
Iterates over elements of collection
, returning the first element
predicate
returns truthy for. The predicate is invoked with three
arguments: (value, index|key, collection).
Returns the first matched element, else undefined
.
var users = [
{ 'user': 'barney', 'age': 36, 'active': true },
{ 'user': 'fred', 'age': 40, 'active': false },
{ 'user': 'pebbles', 'age': 1, 'active': true }
];
find(users, function(o) { return o.age < 40; });
// => object for 'barney'
// The `matches` iteratee shorthand.
find(users, { 'age': 1, 'active': true });
// => object for 'pebbles'
// The `matchesProperty` iteratee shorthand.
find(users, ['active', false]);
// => object for 'fred'
// The `property` iteratee shorthand.
find(users, 'active');
// => object for 'barney'
Iterates over elements of
collection
, returning the first elementpredicate
returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).