As a beginner, please forgive me for asking what may be considered a naive question.
I currently have an array of objects
const arr = [{id: 1, name: 'Pete'}, {id: 5, name: 'John'}, {id: 3, name: 'Peter'}]
and I am looking to transform it using Ramda into the following structure:
const obj = {1 : {id: 1, name: 'Pete'}, 5: {id: 5, name: 'John'}, 3: {id: 3, name: 'Peter'}}
Could someone kindly assist with this?
Other Conceptual Questions:
- I am contemplating converting a nested array of objects into this format in order to optimize searching by
name
when given anid
. Is this approach sound? - Are there any alternative, more efficient methods that could improve search performance within the array?
Many thanks