1const target = { a: [1], b: [2] };
2const source = { a: [2], c: [5] };
3
4const returnedTarget = Object.assign(target, source);
5
6for(var date in source)
7target[date] = [...target[date] || [],...source[date]]
8
9console.log(target);
1var a = {};
2a['fruit'] = "apple";
3
4var b = {};
5b['vegetable'] = "carrot";
6
7var food = Object.assign({}, a, b);
8
9console.log(food);