Function setValueByPath

  • Modifies object in place by setting a value for a property by path defined as array of strings, parent element comes first. Example: setValueByPath({parent: {value: 1}}, ['parent', 'value'], 2); // returns object {parent: {value: 2}}

    Parameters

    • obj: any

      Object to set value in

    • paths: string[]

      An array of strings, parent element comes first

    • value: ValidValueType

      Value to set

    Returns any

    Modified object