Subtract two numbers. Part of Lodash Math since 4.0.0 (stable — not deprecated).
Warning: If one argument is undefined, Lodash returns the other value unchanged — so _.subtract(undefined, 5) is 5, not -5. Prefer null (→ 0) when a missing minuend should mean zero.
Syntax
Call _.subtract. Start with this line.
Lodash
_.subtract(minuend, subtrahend)
Call
What it does
_.subtract(minuend, subtrahend)
Primary signature.
_.subtract(a, b)
Run the math helper on numbers or a collection.
Prefer import subtract from "lodash/subtract" when you want a smaller bundle.
Family. Same Math helpers style as multiply/divide.
Pick. Use the op that matches your formula.
Compatibility
Browser & Runtime Support
_.subtract is a Lodash Math helper since 4.0.0. It uses native subtraction plus Lodash number coercion. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.0.0+
_.subtract()
Available in [email protected] full builds and the lodash/subtract 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
_.subtractLodash 4.0.0+
Bottom line: Safe for production once Lodash is loaded. Prefer import subtract from "lodash/subtract" for smaller bundles. For simple scripts, native - is fine; Lodash shines in functional pipelines and consistent Math helpers.
Yes. Subtraction is not commutative. _.subtract(6, 4) → 2 but _.subtract(4, 6) → -2.
_.subtract() with both undefined returns 0 — the additive identity used by Lodash’s createMathOperation for add/subtract.
When one side is undefined, Lodash returns the other operand unchanged. That is handy for add/multiply, but for subtract it is not the same as 0 − 5. Prefer null (coerces to 0) or guard missing values.
No. _.subtract(0.3, 0.2) matches native 0.3 − 0.2. Use integer cents or a decimal library for money.
Use import subtract from "lodash/subtract" or require("lodash/subtract") for tree-shaking. Full build: import _ from "lodash" then _.subtract.