Can JavaScript group a list of lists into a map like Groovy does with its groupby function?
let grouped = [['1', '44'], ['2', '55'], ['3','42']].reduce((acc, val) => {
acc[val[0]] = (acc[val[0]] || []).concat(val);
return acc;
}, {});
This would result in: { "1": [["1", "44"]], "2": [["2", "55"]], "3": [["3", "42"]] }
I'm new to JavaScript and unsure if the Rhino 1.7 R4 engine supports groupby functionality.