How to convert an array of objects to object with key value pairs

You could use Object.assign and a spread syntax ... for creating a single object with the given array with objects.

var array = [{ name1: "value1" }, { name2: "value2" }],
    object = Object.assign({}, ...array);
    
console.log(object);

Leave a Comment

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.