Подсчет дублирования значений JavaScript
var counts = {};
your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });
Xanthous Xenomorph
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),[]);
var counts = {1,2,3,3,2,4,1,4};
your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });