Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find duplicates in array javascript

let arr = [1, 2, 3, 4, 5, 5];
const seen = new Set();
const duplicates = arr.filter(n => seen.size === seen.add(n).size);
console.log(duplicates); // [ 5 ]
console.log(duplicates.length); // 1
 
PREVIOUS NEXT
Tagged: #find #duplicates #array #javascript
ADD COMMENT
Topic
Name
1+2 =