Convert array to object with Lodash
I was trying to see if I could find a lodash
method that works the same way as index_by from ruby
and I found keyBy:
> const memberships = [{groupId: '1', status: "active"}, {groupId: '2', status: "inactive"}]
> keyBy(memberships, "groupId")
{ '1': { groupId: '1', status: 'active' },
'2': { groupId: '2', status: 'inactive' } }
Funny thing is that on a previous version of lodash
this method was called indexBy, same as the ruby version.