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);
More Related Contents:
- Checking if a key exists in a JavaScript object?
- Most efficient method to groupby on an array of objects
- Convert Array to Object
- What is the difference between ( for… in ) and ( for… of ) statements?
- Firestore Update single item in an array field
- Why does typeof array with objects return “object” and not “array”? [duplicate]
- How to map more than one property from an array of objects
- How can I access and process nested objects, arrays or JSON?
- Sum JavaScript object propertyA values with the same object propertyB in an array of objects
- Filter array of objects with another array of objects
- How to get objects value if its name contains dots?
- Check if object value exists within a Javascript array of objects and if not add a new object to array
- Angular2 component’s “this” is undefined when executing callback function
- Convert JavaScript array of 2 element arrays into object key value pairs
- Perform .join on value in array of objects
- Create a reset of javascript Array prototype when Array.prototype has been modified?
- What’s the difference between “{}” and “[]” while declaring a JavaScript array?
- Deep comparison of objects/arrays [duplicate]
- Count duplicates within an Array of Objects
- How can I use optional chaining with arrays and functions?
- Array.includes() to find object in array
- Find all values by specific key in a deep nested object
- Javascript oddness with array of objects and indexOf
- Filter nested array in object array by array of values
- Lodash create collection from duplicate object keys
- How to merge duplicates in an array of objects and sum a specific property? [duplicate]
- Create a dynamic nested object from array of properties
- Converting Array of Objects into Array of Arrays
- Difference between ( for… in ) and ( for… of ) statements?
- Find object having maximum value for the `id` property in an array of objects