I have an array of objects like
var data = {"part1": [{"id": 1, "a": 50},{"id": 2, "a": 55},{"id": 4, "a": 100}],
"part2":[{"id": 1, "b": 40}, {"id": 3, "b": 45}, {"id": 4, "b": 110}]
};
I need to merge part1 and part2 (preferably with lodash) to get
var result = [
{"id": 1, "a": 50, "b": 40},
{"id": 2, "a": 55},
{"id": 3, "b": 45},
{"id": 4, "a": 100, "b": 110}
];
Note: I need to merge based on id, if it exists, else copy the other objects as they are. The size and order of part1 and part2 will vary and it is possible for them to not have any common id as well.