Comment Comment by c-smile This sample function keyByUsernameReducer(acc, person) { return {...acc, [person.username]: person}; } const peopleObj = peopleArr.reduce(keyByUsernameReducer, {}); has O(n*n) complexity and memory consumption of the same magnitude.This, while being not so functional pure, is better I think: function keyByUsernameReducer(acc, person) { acc[person.username] = person; return acc; } But still... needless function call on each iteration. parent c-smile 7 years ago
This, while being not so functional pure, is better I think:
But still... needless function call on each iteration.