Converts a collection of items to keyed by the specified field name.
items
field
Type of item in the specified items array.
Array of objects.
Field to key by.
Object with key of the field name and value of the entry that corresponds to field.
keyBy( { id: "a", value: 1 }, { id: "b", value: 2 }, "id",);// { a: { id: "a", value: 1 }, b: { id: "b", value: 2 } } Copy
keyBy( { id: "a", value: 1 }, { id: "b", value: 2 }, "id",);// { a: { id: "a", value: 1 }, b: { id: "b", value: 2 } }
Converts a collection of
items
to keyed by the specifiedfield
name.