javascript array group by id

JavaScript
var results = orgs.reduce(function(results, org) {
    (results[org.id] = results[org.id] || []).push(org);
    return results;
}, {})
Source

Also in JavaScript: