I have the following array:
const result = [{ "1": { status: "ok" }, "2": { status: "ok" } }, { "3": { status: "error" } }]
And I want to convert it to a linear map, like this:
{ "1": { status: "ok" }, "2": { status: "ok" }, "3": { status: "error" } }
In an efficient way.
Currently I was doing
let tickets = {};
result.forEach(e => {
tickets = { ...tickets, ...e }
});
which supposes re-creating the map multiple times, with the spread syntax.
Any ideas to achieve the same behavior with a lower cost?