Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to count duplicates in an array javascript

arr.reduce((b,c)=>((b[b.findIndex(d=>d.el===c)]||b[b.push({el:c,count:0})-1]).count++,b),[]);
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #count #duplicates #array #javascript
ADD COMMENT
Topic
Name
5+1 =