I am dealing with an array of objects:
[object, object, object, object, object]
and I need to assign a unique key to each object based on its title:
{test:object, tester:object, foo:object, bar:object, test:object}
This way, instead of accessing the objects using array[0].title
, I can simply use array.test
. However, if there are multiple objects with the same key, the original one is replaced.
Is it possible to achieve this without adding an index value to the key? If not, would it be better to stick with my original approach of using array[0].title
?