Like _.intersection, but each element is mapped through an iteratee before comparison. Order and references follow the first array. Part of Lodash 4.x Array (since 4.0.0).
Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.
Syntax
Call _.intersectionBy on an array. Start with this line.
Lodash
_.intersectionBy([arrays], [iteratee=_.identity])
Call
What it does
_.intersectionBy([arrays], [iteratee=_.identity])
Primary signature.
_.intersectionBy(array)
Call with an array argument.
Prefer import intersectionBy from "lodash/intersectionBy" when you want a smaller bundle.
Library declarations
Lodash
_.intersectionBy([arrays], [iteratee=_.identity])
Parameters
Parameter
Description
arrays
Optional. Arrays to inspect; first sets order
iteratee
Optional. Criterion per element; default identity
Return Value
Return Value
Description
*
New array of intersecting values
Lodash Examples
Example 1 — Official: Math.floor
Floats match when their floors match; the first array’s value is kept.
Shared key. Floor 1 exists in the second array (1.9).
First wins.1.2 is emitted; 1.3 is treated as a duplicate criterion.
3.1 skipped. Floor 3 is not in the second list.
Design. Same “unique intersecting values” idea as _.intersection.
Compatibility
Browser & Runtime Support
_.intersectionBy is a Lodash 4.x Array helper (added in 4.0.0). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.0.0+
_.intersectionBy()
Available in [email protected] full builds and the lodash/intersectionBy modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.0.0+
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
_.intersectionByLodash 4.0.0+
Bottom line: Safe for production once Lodash 4.0.0+ is on the page or in your bundle. Prefer import intersectionBy from "lodash/intersectionBy" for smaller builds. For plain equality without an iteratee, use _.intersection.
Frequently Asked Questions
_.intersectionBy(...arrays, iteratee) is like _.intersection, but each element is mapped through iteratee first. Membership uses SameValueZero on those projected values. Order and references follow the first array.
No. It returns a new array of elements from the first array whose projected value appears in every other list.
Last. Pass every array first, then the iteratee — same pattern as _.differenceBy and other *By helpers.
Yes. A string like "x" is the _.property shorthand — compare objects by that field.
Results are unique by the projected criterion. If Math.floor makes 1.2 and 1.3 equal, only the first matching element from the first array is kept.
Use import intersectionBy from "lodash/intersectionBy" or require("lodash/intersectionBy") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.intersectionBy.