Lodash lodash.info

cloneDeepWith

Lang
since 4.0.0

Arguments

  • * The value to recursively clone.
  • Function The function to customize cloning.

Returns

* the deep cloned value.

This method is like _.cloneWith except that it recursively clones value.

Example of Lodash _.cloneDeepWith

function customizer(value) {
  if (_.isElement(value)) {
    return value.cloneNode(true);
  }
}

var el = _.cloneDeepWith(document.body, customizer);

console.log(el === document.body);
// => false
console.log(el.nodeName);
// => 'BODY'
console.log(el.childNodes.length);
// => 20