Node.js examples for Array:Array Operation
Group by array by accumulator
Array.prototype.$groupBy = function(accumulator) { var result = {}; this.forEach(function(n) { var key = accumulator(n); if (result[key] === undefined) result[key] = []; result[key].push(n);/*from w ww . j a v a 2 s . c om*/ }); return result; };