Function default

  • This method is like set 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.




    const object = {}

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

    Type Parameters

    • T


    • object: T

      The object to modify.

    • path: string | string[]
    • Optional value: any

      The value to set.

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

      The function to customize assigned values.

        • (...any): any
        • Parameters

          • Rest ...any: any[]

          Returns any

    Returns T

    Returns object.