Skip to content

intersect

Get the intersection of multiple arrays.

Usage

js
import { intersect } from 'js-cool'

Signature

typescript
function intersect<T>(...args: T[][]): T[]

Parameters

ParameterTypeDescription
argsT[][]Arrays to intersect

Returns

T[] - Elements present in all arrays.

Examples

js
intersect([1, 2, 3], [2, 3, 4]) // [2, 3]
intersect([1, 2, 3], [2, 3, 4], [3, 4, 5]) // [3]
intersect(['a', 'b'], ['b', 'c']) // ['b']

Released under the MIT License.