_.set(object, path, value)
Sets the value at path of object. If a portion of path doesn't exist, it's created. Arrays are created for missing index properties while objects are created for all other missing properties. Use _.setWith
to customize path creation.
Note: This method mutates object
.
Arguments
object (Object)
: The object to modify.
path (Array|string)
: The path of the property to set.
value (*)
: The value to set.
Returns
(Object)
: Returns object
.