cloneDeepWith

最后更新于:2022-04-02 00:01:46

## cloneDeepWith + [link](./cloneDeepWith "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L9376 "View in source.") + [npm](https://www.npmjs.com/package/lodash.clonedeepwith "See the npm package.") ``` _.cloneDeepWith(value, [customizer]) ``` 这个方法类似 `_.cloneWith`,除了它会递归拷贝 `value`。 ### 参数 1. value (\*) 要深拷贝的值 2. [customizer] (Function) 这个函数定制返回的拷贝值 ### 返回值 (\*) 返回拷贝后的值 ### 示例 ``` function customizer(value) { if (_.isElement(value)) { return value.cloneNode(true); } } var el = _.cloneDeep(document.body, customizer); console.log(el === document.body); // => false console.log(el.nodeName); // => BODY console.log(el.childNodes.length); // => 20 ```
';