Options
All
  • Public
  • Public/Protected
  • All
Menu

Module cloneWith

Index

Functions Lang

Lang Functions

  • default(value: any, customizer: (...any: any[]) => any): any
  • 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).

    since

    5.3.0

    see

    cloneDeepWith

    example
    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

    Parameters

    • value: any

      The value to clone.

    • customizer: (...any: any[]) => any
        • (...any: any[]): any
        • Parameters

          • Rest ...any: any[]

          Returns any

    Returns any

    Returns the cloned value.