.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
collection
(Array|Object): The collection to iterate over.[predicate=.identity]
(Function)_: The function invoked per iteration.
Returns
(boolean): Returns true
if any element passes the predicate check, else false
.
Example
_.some([null, 0, 'yes', false], Boolean);// => truevar 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
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .