var invoiceStudentByGroup = _.mapValues(_.groupBy(invoiceStudent, 'invoice_type'), clist => clist.map(res => _.omit(res, 'invoice_type'))); [ 0: { name: yusup home: bogor } 1: { name: samuel home: jakarta } 2: { name: salsa home: bogor } ] Result [ bogor: [ 0: {name: yusup, home: bogor} 1: {name: salsa, home: bogor} ], Jakarta: [ 0: {name: samuel, home: jakarta} ] ]
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter