Group objects by their properties in JavaScript.