Skip to content

Function: some() ​

ts
function some<T>(collection, predicate): boolean;

Checks whether some items in an array or object match a predicate. 检查数组或对象中是否存在满足断言的元素。

Type Parameters ​

Type ParameterDescription
T extends Record<string, unknown> | readonly unknown[]The source collection type / 源集合类型

Parameters ​

ParameterTypeDescription
collectionTThe source collection / 源集合
predicate(value, key, collection) => booleanThe match predicate / 匹配断言

Returns ​

boolean

true when some items match / 存在匹配项时返回 true

Example ​

ts
some({ a: 1, b: 2 }, (value) => value > 1)
// => true

Since ​

1.2.0

Released under the MIT License.