Object.groupBy()
Object.groupBy() is a JavaScript method in the Object category. Groups iterable elements by the key from a callback. The syntax is Object.groupBy(items, callbackFn). A typical example: Object.groupBy([1,2,3], n => n % 2 === 0 ? "even" : "odd") // {odd: [1,3], even: [2]}. A close sibling is Object.keys(), which returns an array of a given object's own enumerable property names. A close sibling is Object.values(), which returns an array of a given object's own enumerable property values. A close sibling is Object.entries(), which returns an array of key/value pairs. A close sibling is Object.assign(), which copies properties from source objects to a target. More about this category: Object methods for object manipulation — keys, values, assign, and more. Related Object methods: Object.keys(), Object.values(), Object.entries(), Object.assign(), Object.create(), Object.defineProperty(), Object.defineProperties(), Object.freeze(). This page is part of the free JS Reference documentation covering 1027+ methods, each with syntax, parameters, return values, examples, and common pitfalls.