indexBy()

Traverses an array and returns an object with the values from the array placed in the specified indices.

This function is valid in v2.12.0 to v2.24.3. This function has been downloaded 63 times.

Parameters

{Array} arr
Values to be placed in the returned object.
{Function|Array|string} indexer
If a function, it will be passed a value which will be used to index the items in arr. If an array or a string it will be seen as the path within each item in arr to the property by which to index each item.
{Object=} opt_initial Optional, Default:{}
The object that will be augmented and returned.

Returns

{Array}
opt_initial with additional properties names coming from the return values of indexer and the items found in arr.

Required Function

This function directly requires the following function which is included automatically:

  • countBy()
    Creates or augments an object, making new properties that correspond to values in the given array. Each property added will indicate how many items in the array corresponding to those property names.

Requiring Function

This function is directly required by the following function:

  • countBy()
    Creates or augments an object, making new properties that correspond to values in the given array. Each property added will indicate how many items in the array corresponding to those property names.