_.cloneDeepWith

_.cloneDeepWith(value, [customizer])

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

Since

4.0.0

Arguments

  1. value (*): The value to recursively clone.
  2. [customizer] (Function): The function to customize cloning.

Returns

(*): Returns the deep cloned value.

Example

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
doc_Lodash
2016-11-27 16:35:54
Comments
Leave a Comment

Please login to continue.