Skip to content

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 ​

ParameterTypeDescription
itemsreadonly T[]Source array / 源数组
keyKKey to compare / 要比较的 key
valueT[K] | null | undefinedValue to exclude / 要排除的值

Returns ​

T[]

Filtered array / 过滤后的数组

Example ​

ts
excludeByKey([{ id: 1 }, { id: 2 }], 'id', 1) // => [{ id: 2 }]

Since ​

1.5.0

Released under the MIT License.