Quick actions

cmd+k|ctrl+k

Navigation

Languages

Array Of Objects To Object

Snippet info

Language

JavaScript

Visibility

public

Author

marty

Created

2018-08-22T10:52:35Z

Updated

2018-08-22T10:52:35Z

const arrayOfObjects = [{ id: 1, name: "test1", value: "value1" }, { id: 2, name: "test2", value: "value2" }];
console.log(arrayOfObjects);

var newObj = Object.assign({}, ...(arrayOfObjects.map(item => ({ [item.name]: item.value }) )));
console.log(newObj);
INFO