Updates the value at given path of given object. It mutates the object. If path is not found then objects are created
"on the way". If non-objects are found, they are replaced with new plain objects. If primitives are used as source
they are ignored and returned value is empty object with updated value at given path.
Example
set(object, "deep.property", value)
Example
set(object, ["deep", "property"], value)
Example
set({}, "deep[0].property", value) // will create this structure: { "deep[0]": { "property":value }}
Example
set({}, "items.0", value) // will create object, not array { "items": { "0":value }}
Returns
given object or new object if source was primitive
Parameters
source: Source
source object to mutate
path: string | string[]
path where value should be stored, written as dot-separated property names or
array with property names. Use Array when your keys includes dots.
Updates the value at given path of given object. It mutates the object. If path is not found then objects are created "on the way". If non-objects are found, they are replaced with new plain objects. If primitives are used as source they are ignored and returned value is empty object with updated value at given path.
Example
Example
Example
Example
Returns