Reduce array to object using arrow function
问题 I'm playing around with the limits of array and arrow functions and I'm trying to convert this reduce function into an arrow function: var monthsById = months.reduce(function(result, month) { result[month.Id] = month; return result; }, {}); But I'm having trouble to return the map, since result[month.Id] = month; will return the month and not the map like in this approach: var monthsById = months.reduce((byId, month) => byId[month.Id] = month, {}); So I'm looking for a single statement, that