Choose. Objects + average → meanBy; total → sumBy.
Compatibility
Browser & Runtime Support
_.meanBy is a Lodash 4.x Math helper (since 4.7.0). It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native cousin: map + reduce / length.
✓ Stable · Lodash 4.7.0+
_.meanBy()
Available in [email protected] full builds and the lodash/meanBy 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
_.meanByLodash 4.7+
Bottom line: Safe for production once Lodash is loaded. Prefer import meanBy from "lodash/meanBy" for smaller builds. Ideal for averaging object fields.
Frequently Asked Questions
Like _.mean, but each element is projected by an iteratee first. Official: meanBy([{n:4},{n:2},{n:8},{n:6}], 'n') → 5.
A function (value) => number, or a property-path shorthand like 'n' / 'score.value'.
NaN — same empty behavior as _.mean.
mean averages the elements themselves. meanBy averages the iteratee results.
undefined projections are skipped from the sum but still counted in array.length, which pulls the average down.
Use sumBy when you need the total of projected values, not the average.