Function invert

  • 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.

    Type Parameters

    • T

    Parameters

    • object: T

      The object to invert.

    Returns any

    Returns the new inverted object.

    Since

    5.7.0

    Example

    const object = { 'a': 1, 'b': 2, 'c': 1 }

    invert(object)
    // => { '1': 'c', '2': 'b' }