The value to clone.
Optional
customizer: ((...any) => any)The function to customize cloning.
Rest
...any: any[]Returns the cloned value.
5.3.0
cloneDeepWith
function customizer(value) {
if (isElement(value)) {
return value.cloneNode(false)
}
}
const el = cloneWith(document.body, customizer)
console.log(el === document.body)
// => false
console.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).