Finds common elements between both arrays.

Type signature

<T>(xs: T[], ys: T[]) => T[]

Examples

intersection(
  [1, 2, 3, 4, 5],
  [5, 5, 3, 2],
);
// ⇒ [2, 3, 5]
Try in REPL

Questions

  • How to find common elements present in both arrays?

TypeScript sourceJavaScript source