I have an array of items that contains several properties. One of the properties is an array of tags. What is the best way of getting all the tags used in those items and or
Map all tag arrays into a single array, and then countBy
countBy
var tags = _.flatten(_.map(items,d=>d.tags)) tags = _.countBy(tags)
Using underscores chain utility
chain
var tags = _.chain(items).map(d=>d.tags).flatten().countBy().value();