I have a small problem.
I have such an array of objects:
Array
[
0: {
name: "someName",
value: "someValue"
},
1: {
name: "someName",
value: "someValue"
}
...
]
I would like to get:
Object
{
"someName": "someValue",
"someName": "someValue",
...
}
It is very easy to map... but I do not know how to properly assign this to an object
myArray.map(element => console.log(element.name, element.value));
array#reduce.map()was just logging, and not actually mapping to a new array. If each.map()iteration returned a new object with a new key-value pair, you could then use the resulting array withObject.assign.var result = Object.assign({}, ...data.map(element => ({[element.name]: element.value})));.reduce()like this:var result = data.reduce((res, {name, value}) => Object.assign(res, {[name]: value}), {})