Function: excludeByKey()
ts
function excludeByKey<T, K>(
items,
key,
value): T[];Filters out items whose key matches the given value. 按指定 key 与 value 过滤掉数组中的匹配项。
Type Parameters
| Type Parameter |
|---|
T |
K extends string | number | symbol |
Parameters
| Parameter | Type | Description |
|---|---|---|
items | readonly T[] | Source array / 源数组 |
key | K | Key to compare / 要比较的 key |
value | T[K] | null | undefined | Value to exclude / 要排除的值 |
Returns
T[]
Filtered array / 过滤后的数组
Example
ts
excludeByKey([{ id: 1 }, { id: 2 }], 'id', 1) // => [{ id: 2 }]Since
1.5.0