Creates the inverse of an object by making a new object where the keys are the values and the values are the keys.

This function is valid in v2.7.0 to v2.24.2. This function has been downloaded 40 times.


{*} obj
Object whose keys and values will be inverted and returned.
{*=} opt_initial Optional, Default:{}
Object to which the value/key pairs should be added. If not given an empty object will be used.


Adds the value/key pairs found in obj to opt_initial where all of the keys added will be the values from obj and all of the corresponding values will be the keys.

Required Function

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

  • entries()
    Gets an array of pairs (array of length 2) indicating all of the keys and values within a given array or object.