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

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
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; });