Like _.xor, but each element is compared by an iteratee result (function, property, or path). Shared projected keys cancel; exclusive keys keep their original elements. Part of Lodash 4.x Array.
Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.
Syntax
Call _.xorBy on an array. Start with this line.
Lodash
_.xorBy([arrays], [iteratee=_.identity])
Call
What it does
_.xorBy([arrays], [iteratee=_.identity])
Primary signature.
_.xorBy(array)
Call with an array argument.
Prefer import xorBy from "lodash/xorBy" when you want a smaller bundle.
Cancel. Every key pairs off → nothing exclusive left.
Extra fields.tag does not matter — only the iteratee key does.
Safe. Returns []; does not throw.
Compatibility
Browser & Runtime Support
_.xorBy is a Lodash 4.x Array helper. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.x
_.xorBy()
Available in [email protected] full builds and the lodash/xorBy 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
_.xorByLodash 4.x+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import xorBy from "lodash/xorBy" for smaller builds. Not a native browser API — load Lodash first.
Frequently Asked Questions
_.xorBy(...arrays, iteratee) is like _.xor, but it compares each element by the value returned from iteratee. Shared projected keys cancel; exclusive keys keep their original elements.
No. It returns a new array. All argument arrays stay unchanged.
Last. Pass every array first, then the iteratee: _.xorBy(a, b, Math.floor) or _.xorBy(a, b, "id").