_.some

_.some(collection, [predicate=_.identity])

Checks if predicate returns truthy for any element of collection. Iteration is stopped once predicate returns truthy. The predicate is invoked with three arguments: (value, index|key, collection).

Since

0.1.0

Arguments

  1. collection (Array|Object): The collection to iterate over.
  2. [predicate=_.identity] (Function): The function invoked per iteration.

Returns

(boolean): Returns true if any element passes the predicate check, else false.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
_.some([null, 0, 'yes'false], Boolean);
// => true
  
 
var users = [
  'user''barney''active'true },
 
  'user''fred',   'active'false }
];
  
// The `_.matches` iteratee shorthand.
_.some(users, { 'user''barney''active'false });
// => false
  
// The `_.matchesProperty` iteratee shorthand.
_.some(users, ['active'false]);
// => true
  
// The `_.property` iteratee shorthand.
_.some(users, 'active');
// => true
doc_Lodash
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.