A few months ago I wrote a post on the _.get method so for todays post on lodash I might as well write one on _.set as well. The _.set method works just like that of the _.get method in lodash, only it can be used to set a property rather than getting it.
The basic idea of _.set is that a value can be set by just passing the object, and then a path in string format, followed by the value to set the property to.
It’s not like setting a property of an object is all that hard without lodash, but this method allows for setting the value with a string format path which can be helpful in some situations. Another added benefit is that it can also be used to create paths in the event that they are not there as well.