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
cloneexcept that it acceptscustomizerwhich is invoked to produce the cloned value. Ifcustomizerreturnsundefined, cloning is handled by the method instead. Thecustomizeris invoked with one argument (value).