Computes a set difference between the two given arrays.

Type signature

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

Examples

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

Questions

  • How to find elements which are present in the first array and not in the second?

TypeScript sourceJavaScript source