Arrays.hasDuplicates()
Syntax
function hasDuplicates(iterable: Iterable<unknown>): boolean
Checks whether an iterable contains duplicate values or references.
Parameters | |
array
|
The iterable you want to check. |
Example
import { Arrays } from 'potence';
Arrays.hasDuplicates([0, 1, 2]); // -> false
Arrays.hasDuplicates([0, 1, 1]); // -> true
Remarks
This function compares values for value types and references for reference types.
This function uses Set internally to check for duplicates, so prefer to use Set directly if you are able to do so.
Compare
Arrays.distinct()
.