Here are some common approaches:
Using Array.prototype.reduce():
Example:
const array = ['a', 'b', 'c'];
const obj = array.reduce((accumulator, currentValue, index) => {
accumulator[index] = currentValue;
return accumulator;
}, {});
console.log(obj);
// Output: { '0': 'a', '1': 'b', '2': 'c' }
In this example, each element of the array becomes a value in the object, with its index as the corresponding key.