Creates an object composed of the inverted keys and values of object. If object contains duplicate values, subsequent values overwrite property assignments of previous values.
object
The object to invert.
Returns the new inverted object.
5.7.0
const object = { 'a': 1, 'b': 2, 'c': 1 }invert(object)// => { '1': 'c', '2': 'b' } Copy
const object = { 'a': 1, 'b': 2, 'c': 1 }invert(object)// => { '1': 'c', '2': 'b' }
Creates an object composed of the inverted keys and values of
object
. Ifobject
contains duplicate values, subsequent values overwrite property assignments of previous values.