Toolbox-XToolbox-X

Get Duplicates

Finds duplicate values in an array.

getDuplicates

Finds duplicate values in an array and performs a deep comparison for objects and arrays to detect duplicates.

Function Signature

function getDuplicates<T>(array: T[]): T[]

Parameters

  • array (T[]): The array in which to find duplicates.

Returns

  • T[]: An array containing all duplicate entries. Each duplicate entry is only returned once.

Example Usage

playground.ts

Aliases

The following aliases can be used for the getDuplicates function:

  • extractDuplicates
  • extractDuplicatesFromArray
  • getDuplicatesFromArray

Notes

  • The function depends on the isDeepEqual utility to compare values deeply.
  • Data Validation: Check if there are duplicate entries in input data or user selections.
  • Filtering Data: Use it for eliminating duplicate records in a dataset before processing or displaying them.
  • Data Synchronization: Useful in cases where you need to ensure that items in an array are unique, particularly in systems where deep equality matters.

Last updated: Sun, Jun 14, 2026 07:15:25PM (UTC)

On this page