Find All Duplicates

Find all elements that appear more than once in an array using frequency counting.

Code

Algorithms
const count = {};
arr.forEach(x => count[x] = (count[x] || 0) + 1);
return Object.keys(count).filter(k => count[k] > 1).map(Number);

Parameters

Array to check

Browser·fetch() may be limited by CORS

More JavaScript Snippets