function intersect
intersect<T>(...arrays: (readonly T[])[]): T[]Returns all distinct elements that appear at least once in each of the given arrays.
Examples
Example 1
Example 1
import { intersect } from "@std/collections/intersect"; import { assertEquals } from "@std/assert/assert_equals"; const lisaInterests = ["Cooking", "Music", "Hiking"]; const kimInterests = ["Music", "Tennis", "Cooking"]; const commonInterests = intersect(lisaInterests, kimInterests); assertEquals(commonInterests, ["Cooking", "Music"]);
Type Parameters
TParameters
...arrays: (readonly T[])[]Return Type
T[]