javascript - Merge 2 arrays of objects - Stack Overflow


PHOTO EMBED

Mon Jan 25 2021 10:43:06 GMT+0000 (UTC)

Saved by @ali_alaraby #javascript

var arr1 = [{name: "lang", value: "English"},{name: "age", value: "18"}];
var arr2 = [{name : "childs", value: '5'}, {name: "lang", value: "German"}];

Array.prototype.push.apply(arr1,arr2); 

console.log(arr1);  // final merged result will be in arr1
content_copyCOPY

https://stackoverflow.com/questions/7146217/merge-2-arrays-of-objects