Like _.sum, except it accepts an iteratee invoked for each element to generate the value to sum. Part of Lodash Math (stable — not deprecated). The iteratee is called with one argument: (value).
Pass the numbers or collection shown below. Check the return value before you chain another math helper.
Syntax
Call _.sumBy. Start with this line.
Lodash
_.sumBy(array, iteratee)
Call
What it does
_.sumBy(array, iteratee)
Primary signature.
Prefer import sumBy from "lodash/sumBy" when you want a smaller bundle.
Library declarations
Lodash
_.sumBy(array, iteratee)
Parameters
Parameter
Description
array
Required. Array to iterate over
iteratee
Optional. Function or property path; invoked as (value)
_.sumBy is a Lodash Math helper available in 4.x (and earlier builds). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native equivalents map then reduce; Lodash adds iteratee shorthands and skips undefined results.
✓ Stable · Lodash 4.x
_.sumBy()
Available in [email protected] full builds and the lodash/sumBy 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
_.sumByLodash 4.x
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import sumBy from "lodash/sumBy" for smaller builds. Use property shorthand for simple fields; use a function for computed values.
Frequently Asked Questions
_.sumBy(array, iteratee) is like _.sum, but each element is passed through an iteratee first. Official docs: sum objects by function or by property shorthand 'n' → 20.
_.sum adds raw array values. _.sumBy maps each element with an iteratee (function or property path) then adds those numbers. Without a useful iteratee on objects, prefer _.sum on a flat number list.
When the iteratee returns undefined (for example a missing field), that row is skipped. The total is the sum of rows that had a value — not NaN.
If any iteratee return is a string, native + switches to concatenation. Coerce inside the iteratee: _.sumBy(rows, r => Number(r.price)).
_.sumBy skips undefined iteratee results and has no divisor. _.meanBy still divides by array.length, so missing fields can lower the average.
Use import sumBy from "lodash/sumBy" or require("lodash/sumBy") so bundlers can tree-shake. Full build: import _ from "lodash" then _.sumBy.