Function default

  • This method is like cloneWith except that it recursively clones value. The customizer is invoked with up to four arguments (value [, index|key, object, stack]).

    Parameters

    • value: any

      The value to recursively clone.

    • customizer: ((...any) => any)

      The function to customize cloning.

        • (...any): any
        • Parameters

          • Rest ...any: any[]
            Rest

          Returns any

    Returns any

    Returns the deep cloned value.

    Since

    5.3.0

    See

    cloneWith

    Example

    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