find duplicates and their count in an array javascript

Solutions on MaxInterview for find duplicates and their count in an array javascript by the best coders in the world

showing results for - "find duplicates and their count in an array javascript"
Lya
27 Sep 2017
1var counts = {};
2your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });