Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

lodash count duplicates in array

const data = ["apple", "banana", "apple", "orange", "grapes", "mango", "banana"];

const result = _.values(_.groupBy(data)).map(d => ({name: d[0], count: d.length}));

console.log(result);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #lodash #count #duplicates #array
ADD COMMENT
Topic
Name
2+1 =