Lists all the duplicated values in the given array.

Type signature

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

Examples

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

Questions

  • How to find duplicates in an array?

TypeScript sourceJavaScript source