_.updateWith(object, path, updater, [customizer])
This method is like _.update
except that it accepts customizer
which is invoked to produce the objects of path
. If customizer
returns undefined
path creation is handled by the method instead. The customizer
is invoked with three arguments: (nsValue, key, nsObject).Note: This method mutates object
.
Since
4.6.0
Arguments
object
(Object): The object to modify.path
(Array|string): The path of the property to set.updater
(Function): The function to produce the updated value.[customizer]
(Function): The function to customize assigned values.
Returns
(Object): Returns object
.
Example
var object = {};_.updateWith(object, '[0][1]', _.constant('a'), Object);// => { '0': { '1': 'a' } }
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .