let items = [
{name: "something", value: true},
// ...
];
// equivalent as as a for loop
let result = {};
for(let item of items) {
result[item.name] = item.value;
}
// use reduce to build the new map into an accumulator
// we'll refer to this as "reduce mutate"
let result = items.reduce((acc, item) => {
acc[item.name] = item.value;
return acc;
}, {})
// we'll call this "reduce ...spread"
let result = items.reduce((acc, item) => ({
...acc, [item.name]: item.value
}), {})