const items = [{id: 1, name: "First"}, {id: 2, name: "Second"}, {id: 3, name: "Third"}];
const itemLookup = makeObjectFromArrayMap(items, e => [e.id, e]);
// result: {1: {id: 1, name: "First"}, 2: {id: 2, name: "Second"}, 3: {id: 3, name: "Third"}}
const itemId = 3;
const item = itemLookup[itemId];
Returns an object using the entries resulting from applying the given
mapfunction to the givenarray.This function optimizes the use of
makeObjectFromEntriesin conjuction withArray.mapso that only one loop is needed instead of two (half as many iterations). In other words, is equivalent tomakeObjectFromEntries(array.map(map)).