4.17.11
3.10.1
2.4.2
1.3.1
_.assignInWith(object, sources, [customizer])
This method is like _.assignIn
except that it accepts customizer
which is invoked to produce the assigned values. If customizer
returns
undefined
, assignment is handled by the method instead. The customizer
is invoked with five arguments: (objValue, srcValue, key, object, source).
Note: This method mutates object
.
Since
4.0.0
Arguments
argument
object
sources
[customizer]
type
Object
...Object
Function
description
The destination object.
The source objects.
The function to customize assigned values.
Returns
(array)
Example
function customizer(
objValue,
srcValue
) {
return _.isUndefined(objValue)
? srcValue
: objValue;
}
var defaults = _.partialRight(
_.assignInWith,
customizer
);
defaults({ a: 1 }, { b: 2 }, { a: 3 });
// => { 'a': 1, 'b': 2 }
function customizer(objValue, srcValue) {
return _.isUndefined(objValue) ? srcValue : objValue;
}
var defaults = _.partialRight(_.assignInWith, customizer);
defaults({ a: 1 }, { b: 2 }, { a: 3 });
// => { 'a': 1, 'b': 2 }