This method is like _.set except that it accepts an updater to produce the value to set. Mutates object and returns it. Part of Lodash 4.x Object (since 4.6.0).
Pass the object and path or keys shown below. Check whether the helper mutates or returns a new object.
Syntax
Call _.update. Start with this line.
Lodash
_.update(object, path, updater)
Call
What it does
_.update(object, path, updater)
Primary signature.
_.update(object)
Work with an object’s keys, values, or paths.
Prefer import update from "lodash/update" when you want a smaller bundle.
Library declarations
Lodash
_.update(object, path, updater)
Parameters
Parameter
Description
object
Required. Target object (mutated)
path
Required. Dot/bracket string or key array
updater
Required. (value) => newValue
Return Value
Return Value
Description
*
The same object reference
Lodash Examples
Example 1 — Official: Square Nested Value
Read c, square it, write it back.
Lodash
var object = { a: [{ b: { c: 3 } }] };
_.update(object, "a[0].b.c", function (n) {
return n * n;
});
object.a[0].b.c;
// → 9
_.update is a Lodash Object helper (since 4.6.0). It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Closest pattern is _.set(obj, path, updater(_.get(obj, path))); Lodash packages that into one call with shared path parsing.
✓ Stable · Lodash 4.x
_.update()
Available in [email protected] full builds and the lodash/update modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.updateLodash 4.6+
Bottom line: Safe for production once Lodash is loaded. Prefer import update from "lodash/update" for smaller builds. Ideal for toggles, counters, and derived nested writes.
Frequently Asked Questions
_.update(object, path, updater) reads the value at path, passes it to updater, and writes the return value back. Mutates object and returns it.
set assigns a finished value. update computes the new value from the current one — toggles, increments, string transforms.
The updater receives undefined. Lodash still creates intermediate containers when writing the result (like set).
Yes. Clone first when you need immutability: _.update(_.cloneDeep(obj), path, fn).
When you need a customizer to control how missing intermediate objects/arrays are created along the path.
Use import update from "lodash/update" or require("lodash/update"). Full build: import _ from "lodash" then _.update.