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 :
The lodash implementaiton:
var merged = _.map(a1, function(item) { return _.assign(item, _.find(a2, ['id', item.id])); });
The result:
[ { "id":1, "name":"test", "count":"1" }, { "id":2, "name":"test2", "count":"2" } ]