企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## cloneWith + [link](./cloneWith "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L9326 "View in source.") + [npm](https://www.npmjs.com/package/lodash.clonewith "See the npm package.") ``` _.cloneWith(value, [customizer]) ``` 这个方法类似 `_.clone`,除了它接受一个 `customizer` 定制返回的拷贝值。 如果 `customizer` 返回 `undefined` 将会拷贝处理方法代替。 `customizer` 会传入5个参数:(value [, index|key, object, stack]) ### 参数 1. value (\*) 要拷贝的值 2. [customizer] (Function) 这个函数定制返回的拷贝值 ### 返回值 (\*) 返回拷贝后的值 ### 示例 ``` function customizer(value) { if (_.isElement(value)) { return value.cloneNode(false); } } var el = _.cloneWith(document.body, customizer); console.log(el === document.body); // => false console.log(el.nodeName); // => 'BODY' console.log(el.childNodes.length); // => 0 ```