Function updateWith

  • This method is like update except that it accepts customizer which is invoked to produce the objects of path. If customizer returns undefined path creation is handled by the method instead. The customizer is invoked with three arguments: (nsValue, key, nsObject).

    Note: This method mutates object.

    Type Parameters

    • T

    Parameters

    • object: T

      The object to modify.

    • path: string | string[]

      The path of the property to set.

    • Optional updater: ((...any) => any)

      The function to produce the updated value.

      Optional
        • (...any): any
        • Parameters

          • Rest ...any: any[]
            Rest

          Returns any

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

      The function to customize assigned values.

      Optional
        • (...any): any
        • Parameters

          • Rest ...any: any[]
            Rest

          Returns any

    Returns T

    Returns object.

    Since

    5.3.0

    Example

    const object = {}

    updateWith(object, '[0][1]', () => 'a', Object)
    // => { '0': { '1': 'a' } }