Skip to main content

updateWith

_.updateWith(customizer, path, updater, object) # Ⓢ [Ⓣ][1] Ⓝ

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).




Since​

4.6.0

Arguments​

  1. customizer (Function): The function to customize assigned values.
  2. path (Array|string): The path of the property to set.
  3. updater (Function): The function to produce the updated value.
  4. object (Object): The object to modify.

Returns​

(Object): Returns object.

Example​

var object = {};

_.updateWith(Object, '[0][1]', _.constant('a'), object);
// => { '0': { '1': 'a' } }