Skip to main content
Go to Latest
function intersect
import { intersect } from "https://deno.land/std@0.102.0/collections/intersect.ts";

Returns all distinct elements that appear at least once in each of the given arrays

Example:

const lisaInterests = [ 'Cooking', 'Music', 'Hiking' ]
const kimInterests = [ 'Music', 'Tennis', 'Cooking' ]
const commonInterests = intersectTest(lisaInterests, kimInterests)

console.assert(commonInterests === [ 'Cooking', 'Music' ])

Parameters

...arrays: Array<Array<T>>

Returns

Array<T>