groupBy()

Takes an array and groups the items together based on a given hasher function.

This function is valid in v2.0.0 to v2.11.0. This function has been downloaded 0 times.

Parameters

{Array} arr
Array containing the items to be grouped by the hasher function.
{function(*, number, Array)} hasher
Function that will take item in the array and and return a value to be used as the key in the returned object.
{*=} opt_initial Optional, Default:{}
Object that will be augmented and returned. The values at the keys produced by hasher will be arrays containing all of the corresponding items from arr. If not specified the default is a new empty object.

Returns

{*}
opt_initial with all of the keys specified by hasher corresponding to arrays containing those values that come from arr.

Required Functions

This function directly requires the following functions which are included automatically:

  • has()
    Every object descended from Object inherits the hasOwnProperty method. This method can be used to determine whether an object has the specified property as a direct property of that object; unlike the in operator, this method does not check down the object's prototype chain.
  • typeOf()
    Either gets the type of a value or adds a constructor registering its custom type name.