Finds common elements between both arrays.

Type signature

(xs: any[], ys: any[]) => any[]

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