findDuplicates
The findDuplicates() function returns duplicated values from an array and keeps a single occurrence for each duplicated value.
Interactive example
Syntax
Classic signature
typescript
function findDuplicates<
GenericInput extends readonly EligibleDuplicateElement[],
>(
array: GenericInput,
): undefined | AnyTuple<GenericInput[number]>Parameters
array: Input array to scan for duplicates.
Return value
Returns undefined when no duplicate is found, otherwise returns a tuple containing duplicated values (one occurrence per value).
