Find number of occurences of string elements in an Array using lodash or underscore js
问题 I have an array in the following format: var array = [ { id: '555weibo' }, { id: '578weibo' }, { id: '111facebook' }, { id: '123facebook' }, { id: '145facebookpage' }, { id: '145facebookpage' }, { id: '766facebook' }, { id: '242facebook' }, { id: '432twitter' }, { id: '432exing' } ]; I need to find the number of occurrences of facebook , twitter , xing , and weibo inside that array. eg: { weibo: 2, facebook: 6, twitter: 1, xing: 1 } I've searched for a solution, but nothing seems to work. The