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 one argument (value).
clone
customizer
undefined
The value to clone.
Optional
The function to customize cloning.
Returns the cloned value.
4.0.0
cloneDeepWith
function customizer(value) { if (isElement(value)) { return value.cloneNode(false) }}const el = cloneWith(document.body, customizer)console.log(el === document.body)// => falseconsole.log(el.nodeName)// => 'BODY'console.log(el.childNodes.length)// => 0 Copy
function customizer(value) { if (isElement(value)) { return value.cloneNode(false) }}const el = cloneWith(document.body, customizer)console.log(el === document.body)// => falseconsole.log(el.nodeName)// => 'BODY'console.log(el.childNodes.length)// => 0
This method is like
clone
except that it acceptscustomizer
which is invoked to produce the cloned value. Ifcustomizer
returnsundefined
, cloning is handled by the method instead. Thecustomizer
is invoked with one argument (value).