Function: some()
ts
function some<T>(collection, predicate): boolean;Checks whether some items in an array or object match a predicate. 检查数组或对象中是否存在满足断言的元素。
Type Parameters
| Type Parameter | Description |
|---|---|
T extends Record<string, unknown> | readonly unknown[] | The source collection type / 源集合类型 |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T | The source collection / 源集合 |
predicate | (value, key, collection) => boolean | The match predicate / 匹配断言 |
Returns
boolean
true when some items match / 存在匹配项时返回 true
Example
ts
some({ a: 1, b: 2 }, (value) => value > 1)
// => trueSince
1.2.0