Function default

  • This method is like clone except that it accepts customizer which is invoked to produce the cloned value. If customizer returns undefined, cloning is handled by the method instead. The customizer is invoked with one argument (value).

    Parameters

    • value: any

      The value to clone.

    • Optionalcustomizer: ((...any: any[]) => any)

      The function to customize cloning.

        • (...any): any
        • Parameters

          • Rest...any: any[]

          Returns any

    Returns any

    Returns the cloned value.

    5.3.0

    cloneDeepWith

    function customizer(value) {
    if (isElement(value)) {
    return value.cloneNode(false)
    }
    }

    const el = cloneWith(document.body, customizer)

    console.log(el === document.body)
    // => false
    console.log(el.nodeName)
    // => 'BODY'
    console.log(el.childNodes.length)
    // => 0