Plain numbers. Prefer _.max / _.min without an iteratee.
Compatibility
Browser & Runtime Support
_.maxBy is a Lodash 4.x Math helper (since 4.0.0). It needs no special browser APIs beyond loading Lodash.
✓ Stable · Lodash 4.0.0+
_.maxBy()
Available in [email protected] full builds and the lodash/maxBy modular import. Works in evergreen browsers and Node / Bun / Deno 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
_.maxByLodash 4.x+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import maxBy from "lodash/maxBy" for smaller builds.
Frequently Asked Questions
_.maxBy(array, [iteratee=_.identity]) returns the element whose iteratee result is greatest. Official docs: _.maxBy([{n:1},{n:2}], 'n') → {n:2}.
The original array element that wins, not the iteratee number. You get the object back, not just 2.
Yes. Lodash supports property shorthand such as 'n' or nested paths like 'score.value'.
_.maxBy([]) returns undefined — same empty/falsey rule as _.max.
_.max compares elements as-is and takes no iteratee. _.maxBy ranks by iteratee results — use it for objects.
Use import maxBy from "lodash/maxBy" or require("lodash/maxBy") for tree-shaking. Full build: import _ from "lodash" then _.maxBy.