How to merge objects into a single object array with JavaScript?



Following is the code to merge objects into a single object array −

Example

 Live Demo






Document



Merge objects into a single object array

[{id:22, class:7},{name:'Rohan', age:12},{state:'Delhi',country:'India'}]

Click on the above button to merge the above objects inside array into a single object

Output

The above code will produce the following output −

On clicking the ‘CLICK HERE’ button −

Updated on: 2020-07-21T07:35:17+05:30

243 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements