Checks if predicate returns truthy for all elements of collection. Iteration is stopped once predicate returns falsey. The predicate is invoked with three arguments: (value, index|key, collection).
predicate
collection
Note: This method returns true for empty collections because everything is true of elements of empty collections.
true
5.3.0
every([true, 1, null, 'yes'], Boolean);// => falsevar users = [ { 'user': 'barney', 'age': 36, 'active': false }, { 'user': 'fred', 'age': 40, 'active': false }];// The `matches` iteratee shorthand.every(users, { 'user': 'barney', 'active': false });// => false// The `matchesProperty` iteratee shorthand.every(users, ['active', false]);// => true// The `property` iteratee shorthand.every(users, 'active');// => false Copy
every([true, 1, null, 'yes'], Boolean);// => falsevar users = [ { 'user': 'barney', 'age': 36, 'active': false }, { 'user': 'fred', 'age': 40, 'active': false }];// The `matches` iteratee shorthand.every(users, { 'user': 'barney', 'active': false });// => false// The `matchesProperty` iteratee shorthand.every(users, ['active', false]);// => true// The `property` iteratee shorthand.every(users, 'active');// => false
The collection to iterate over.
Optional
The function invoked per iteration.
Enables use as an iteratee for methods like map.
map
Returns true if all elements pass the predicate check, else false.
false
Checks if
predicate
returns truthy for all elements ofcollection
. Iteration is stopped oncepredicate
returns falsey. The predicate is invoked with three arguments: (value, index|key, collection).Note: This method returns
true
for empty collections because everything is true of elements of empty collections.Since
5.3.0
Example