Invokes interceptor and returns value. Use it to “tap into” a method chain for side effects or intermediate mutations. Part of Lodash Seq (since 0.1.0).
Pass the value you want to wrap or transform. Finish with .value() when the result stays wrapped.
Syntax
Call _.tap. Start with this line.
Lodash
_.tap(value, interceptor)
Call
What it does
_.tap(value, interceptor)
Primary signature.
_.tap(value)
Wrap or control a Lodash sequence.
Prefer import tap from "lodash/tap" when you want a smaller bundle.
Library declarations
Lodash
_.tap(value, interceptor)
Parameters
Parameter
Description
value
Required. Passed to the interceptor; also returned
Same ref. Chain continues with that mutated array.
Map. Multiply each by 10.
Result.[10, 20, 30, 40].
Compatibility
Browser & Runtime Support
_.tap is a Lodash Seq method (since 0.1.0). It needs no special browser APIs beyond loading Lodash.
✓ Stable · Lodash 0.1.0+
_.tap()
Available in [email protected] full builds and modular builds that include Seq helpers. Works in evergreen browsers and Node / Bun / Deno when Lodash is installed.
100%With Lodash
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
_.tapLodash 0.1.0+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer the full lodash build for Seq chaining.
Frequently Asked Questions
_.tap(value, interceptor) invokes interceptor(value) for side effects, then returns value. Official docs: tap into a chain to modify intermediate results (often by mutation).
No. Lodash always returns the original value. Use _.thru() if you want the interceptor’s return to become the next chain value.
_([1,2,3]).tap(array => array.pop()).reverse().value() → [2, 1]. The tap pops 3, then reverse yields [2, 1].
tap returns the original value; thru returns whatever the interceptor returns.
Yes. _.tap(value, fn) works standalone — it still calls fn(value) and returns value.
Logging, debugging, metrics, or mutating intermediate data inside a chain without replacing the piped value via return.