cloneWith
_.cloneWith(customizer, value)
# Ⓢ [Ⓣ][1] Ⓝ
This method is like _.clone except that it accepts customizer which
is invoked to produce the cloned value. If customizer returns undefined,
cloning is handled by the method instead. The customizer is invoked with
up to four arguments; (value [, index|key, object, stack]).
Since
4.0.0
Arguments
customizer(Function): The function to customize cloning.value(*): The value to clone.
Returns
(*): Returns the cloned value.
Example
function customizer(value) {
if (_.isElement(value)) {
return value.cloneNode(false);
}
}
var el = _.cloneWith(customizer, document.body);
// => false
// => 'BODY'
// => 0