index()

Indexes the target object based on the items found in subject and the callback function.

This function is valid in v2.7.0 to v2.12.0. This function has been downloaded 10 times.

Parameters

{Array|Object} subject
Array or object to traverse.
{Object} target
Object that will be augmented based on the items traversed in subject.
{Function} callback
Function called for each item within subject. In order to augment target, the return value must be an object (or array) that either has the key and value properties defined, 0 and 1 (for an array) values defined, or k and v properties defined. All other types of values returned from this function will be ignored.

Returns

{Object|Array}
A reference to target.

Required Functions

This function 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.
  • forOf()
    Traverses all the characters in a string or all of the items in an array or an object, executing a function on each one.