Created
May 22, 2019 08:10
-
-
Save progging/1159726f2704ca06641ab2a41f408584 to your computer and use it in GitHub Desktop.
Group by multiple properties using lodash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const items = [ | |
{ key1: "el200", key2: "id001", value: "bulb tumeric hell of hot chicken" }, | |
{ key1: "el200", key2: "id001", value: "iceland shaman fashion axe squid vice" }, | |
{ key1: "el200", key2: "id001", value: "pin venmo letterpress cloud bread" }, | |
{ key1: "el400", key2: "id002", value: "YOLO flexitarian, swag sriracha" }, | |
{ key1: "el500", key2: "id002", value: "health goth chillwave" } | |
]; | |
const grouped = _.groupBy(items, item => `"${item.key1}+${item.key2}"`); | |
console.log(grouped); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment