Toolbox-XToolbox-X

Remove Duplicates

Removes duplicate values from an array.

removeDuplicatesFromArray

The removeDuplicatesFromArray function removes duplicate values from an array using deep equality checks, ensuring that complex objects and nested arrays are properly compared.

Function Signature

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

Parameters

  • array (T[]): The array from which duplicates will be removed. The array can contain primitive values (strings, numbers, booleans) or objects/arrays that will be compared deeply.

Return Value

  • T[]: A new array with all duplicates removed, preserving the original order of unique elements.

Example Usage

playground.ts

Notes

  • The function uses deep equality checks (isDeepEqual) to compare objects and arrays, ensuring that duplicate objects or arrays with identical contents are removed.
  • The order of elements in the original array is preserved, and only unique items remain in the returned array.
  • Does not mutate the original array.

Aliases

The following aliases can be used for the removeDuplicatesFromArray function:

  • removeDuplicates

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

On this page