Merge objects in JavaScript (lodash) const mergeWith = require('lodash/mergeWith') const isArray = require('lodash/isArray') function mergeObjects(obj1, obj2) { return mergeWith(obj1, obj2, (objValue, srcValue) => { if (isArray(objValue) && isArray(srcValue)) { return objValue.concat(srcValue); } }); } const obj1 = { a: {}, b: { c: [1, 2 , 3], f: [] } } const obj2 = { b: { c: [4, 5 , 6] }, d: null } console.log(mergeObjects(obj1, obj2)) // >> { a: {}, b: { c: [ 1, 2, 3, 4, 5, 6 ], f: [] }, d: null }