set
_.set(path, value, object)
# Ⓢ [Ⓣ][1] Ⓝ
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.
Since
3.7.0
Arguments
path(Array|string): The path of the property to set.value(*): The value to set.object(Object): The object to modify.
Returns
(Object): Returns object.
Example
var object = { 'a': [{ 'b': { 'c': 3 } }] };
_.set('a[0].b.c', 4, object);
// => 4
_.set(['x', '0', 'y', 'z'], 5, object);
// => 5