outJSON = [{ team: "TeamA", name: "Ahmed", field3: "val3" }, { team: "TeamB", name: "Ahmed", field3: "val43" }, { team: "TeamA", name: "Ahmed", field3: "val55" }] var groupBy = function(xs, key) { return xs.reduce(function(rv, x) { (rv[x[key]] = rv[x[key]] || []).push(x); return rv; }, {}); }; var groubedByTeam = groupBy(outJSON, 'team') console.log(groubedByTeam);
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