1. Array to object
The spread operator(...)
Here's a quick and easy way
const arr = ['one','two','three'];
const obj = {...arr}; console.log(obj); // { 0: 'one', 1: 'tow', 2: 'three' }
Objcet.assign(target, ...sources)
2.foreach
const classList = {};
classListItem.forEach((item) => {
classList[item.id] = item.tagName;
});
3.reduce
const valueEnumBase = baseList.reduce((p, c) => Object.assign(p, { [c.symbol]: c.symbol }), {})
There are many other methods, these are the most common ones.