check if array has duplicates value code example
Example 1: javascript check if array has duplicates
function hasDuplicates(array) {
return (new Set(array)).size !== array.length;
}
Example 2: check for duplicates in array javascript
[1, 2, 2, 4, 3, 4].filter((e, i, a) => a.indexOf(e) !== i) // [2, 4]