zipObject source npm

_.zipObject(props, [values=[]])

The inverse of _.pairs; this method returns an object composed from arrays of property names and values. Provide either a single two dimensional array, e.g. [[key1, value1], [key2, value2]] or two arrays, one of property names and one of corresponding values.

Arguments

  1. props (Array)

    The property names.

  2. [values=[]] (Array)

    The property values.

Returns (Object)

Returns the new object.

Example

_.zipObject([['fred', 30], ['barney', 40]]);
// => { 'fred': 30, 'barney': 40 }

_.zipObject(['fred', 'barney'], [30, 40]);
// => { 'fred': 30, 'barney': 40 }