Returns object.
function customizer(objValue, srcValue) {
if (_.isArray(objValue)) {
return objValue.concat(srcValue);
}
}
var object = {
'fruits': ['apple'],
'vegetables': ['beet']
};
var other = {
'fruits': ['banana'],
'vegetables': ['carrot']
};
_.mergeWith(object, other, customizer);
// => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
This method is like
_.mergeexcept that it acceptscustomizerwhich is invoked to produce the merged values of the destination and source properties. Ifcustomizerreturnsundefinedmerging is handled by the method instead. Thecustomizeris invoked with six arguments: (objValue, srcValue, key, object, source, stack).