@pmun/utils / intersection
Function: intersection()
ts
function intersection<T>(...arrays): T[];返回所有数组的交集(所有数组中都存在的元素)
Type Parameters
T
T
Parameters
arrays
...T[][]
要比较的数组
Returns
T[]
交集数组
Example
ts
intersection([1, 2, 3], [2, 3, 4], [2, 3, 5]) // [2, 3]
intersection([1, 2], [2, 3], [3, 4]) // [](没有共同元素)
intersection(['a', 'b'], ['b', 'c'], ['b', 'd']) // ['b']