Skip to content

intersection

intersection<T>(iterables, comparisonStrategy?): Iterable<T>

Defined in: set/intersection.ts:17

Computes the intersection of any number of iterables.

Time complexity: O(n) total across every source iterable — one Set is built per iterable after the first, and the running result is filtered against it, rather than re-scanning an array per candidate (which would make this quadratic). That holds under the default "sameValueZero".

T

readonly Iterable<T, any, any>[]

The iterables to intersect.

EqualityComparisonStrategy<T, T> = "sameValueZero"

The equality comparison strategy to use.

Iterable<T>

An iterable containing only the elements common to every input iterable.