Function cloneDeepWith

  • 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]).

    Type Parameters

    • T

    Parameters

    • value: T

      The value to recursively clone.

    • Optionalcustomizer: ((value: T, key?: PropertyName, object?: any) => any)

      The function to customize cloning.

        • (value, key?, object?): any
        • Parameters

          • value: T
          • Optionalkey: PropertyName
          • Optionalobject: any

          Returns any

    Returns any

    Returns the deep cloned value.

    4.0.0

    cloneWith

    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