This method is like `cloneWith` except that it recursively clones `value`.
function customizer(value) {
if (isElement(value)) {
return value.cloneNode(true)
}
}
const el = cloneDeepWith(document.body, customizer)
console.log(el === document.body)
// => false
console.log(el.nodeName)
// => 'BODY'
console.log(el.childNodes.length)
// => 20
| Name | Type | Attribute | Description |
|---|---|---|---|
| value | The value to recursively clone. | ||
| customizer | The function to customize cloning. |
*
{
"comment": "/**\r\n * This method is like `cloneWith` except that it recursively clones `value`.\r\n *\r\n * @since 4.0.0\r\n * @category Lang\r\n * @param {*} value The value to recursively clone.\r\n * @param {Function} [customizer] The function to customize cloning.\r\n * @returns {*} Returns the deep cloned value.\r\n * @see cloneWith\r\n * @example\r\n *\r\n * function customizer(value) {\r\n * if (isElement(value)) {\r\n * return value.cloneNode(true)\r\n * }\r\n * }\r\n *\r\n * const el = cloneDeepWith(document.body, customizer)\r\n *\r\n * console.log(el === document.body)\r\n * // => false\r\n * console.log(el.nodeName)\r\n * // => 'BODY'\r\n * console.log(el.childNodes.length)\r\n * // => 20\r\n */",
"meta": {
"range": [
822,
1018
],
"filename": "cloneDeepWith.js",
"lineno": 33,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100000627",
"name": "cloneDeepWith",
"type": "FunctionDeclaration",
"paramnames": [
"value",
"customizer"
]
},
"vars": {
"customizer": "cloneDeepWith~customizer"
}
},
"description": "This method is like `cloneWith` except that it recursively clones `value`.",
"since": "4.0.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Lang",
"value": "Lang"
}
],
"params": [
{
"type": {
"names": [
"*"
]
},
"description": "The value to recursively clone.",
"name": "value"
},
{
"type": {
"names": [
"function"
]
},
"optional": true,
"description": "The function to customize cloning.",
"name": "customizer"
}
],
"returns": [
{
"type": {
"names": [
"*"
]
},
"description": "Returns the deep cloned value."
}
],
"see": [
"cloneWith"
],
"examples": [
"function customizer(value) {\r if (isElement(value)) {\r return value.cloneNode(true)\r }\r}\r\rconst el = cloneDeepWith(document.body, customizer)\r\rconsole.log(el === document.body)\r// => false\rconsole.log(el.nodeName)\r// => 'BODY'\rconsole.log(el.childNodes.length)\r// => 20"
],
"name": "cloneDeepWith",
"longname": "cloneDeepWith",
"kind": "function",
"scope": "global",
"___id": "T000002R000068",
"___s": true,
"filepath": "cloneDeepWith.js"
}