Skip to content

Function: intersection()

ts
function intersection<T>(...arrays): T[];

Returns the intersection of multiple arrays. 返回多个数组的交集。

Type Parameters

Type ParameterDescription
TThe array item type / 数组元素类型

Parameters

ParameterTypeDescription
...arraysreadonly readonly T[][]The input arrays / 输入数组

Returns

T[]

A new array containing shared items / 包含共有元素的新数组

Example

ts
intersection([1, 2, 3], [2, 3, 4])
// => [2, 3]

Since

1.2.0

Released under the MIT License.