This method is like cloneWith except that it recursively clones value. The customizer is invoked with up to four arguments (value [, index|key, object, stack]).
cloneWith
value
The value to recursively clone.
Optional
The function to customize cloning.
Returns the deep cloned value.
4.0.0
function customizer(value) { if (isElement(value)) { return value.cloneNode(true) }}const el = cloneDeepWith(document.body, customizer)console.log(el === document.body)// => falseconsole.log(el.nodeName)// => 'BODY'console.log(el.childNodes.length)// => 20 Copy
function customizer(value) { if (isElement(value)) { return value.cloneNode(true) }}const el = cloneDeepWith(document.body, customizer)console.log(el === document.body)// => falseconsole.log(el.nodeName)// => 'BODY'console.log(el.childNodes.length)// => 20
This method is like
cloneWith
except that it recursively clonesvalue
. The customizer is invoked with up to four arguments (value [, index|key, object, stack]).