What\'s the correct way to merge two arrays in Javascript?
I\'ve got two arrays (for example):
var a1 = [{ id : 1, name : \"test\"}, { id : 2, name :
try this
var a1 = [{ id : 1, name : "test"}, { id : 2, name : "test2"}] var a2 = [{ id : 1, count : "1"}, {id : 2, count : "2"}] let arr3 = a1.map((item, i) => Object.assign({}, item, a2[i])); console.log(arr3);