how to count duplicates in an array javascript

JavaScript
uniqueCount = ["a","b","c","d","d","e","a","b","c","f","g","h","h","h","e","a"];
var count = {};
uniqueCount.forEach(function(i) { count[i] = (count[i]||0) + 1;});
console.log(count);var counts = {};
your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });arr.reduce((b,c)=>((b[b.findIndex(d=>d.el===c)]||b[b.push({el:c,count:0})-1]).count++,b),[]);
Source

Also in JavaScript: