Ramda’s R.max() answers a selection question: which of two ordered values is larger? You pass two values and get back one of them — the larger. It uses JavaScript’s ordering rules under the hood, so numbers, strings, and Dates all work. It is not a Boolean test — cousins R.gt and R.gte tell you whether ordering holds. R.min picks the smaller value; R.maxBy picks by a computed key. R.clamp uses ordering internally to bound a value. Previous helper is R.lte. Next is R.maxBy.
The official samples cover the whole idea. R.max(789, 123) returns 789. R.max('a', 'b') returns 'b' because 'b' is lexicographically greater. The result is always one of the two inputs, ready to pipe forward.
Syntax
Call R.max. Start with this line.
Ramda
R.max(a, b)
Call
What it does
R.max(a, b)
Primary signature.
R.max(...)
Call the relation helper.
Prefer import { max } from "ramda" when you want a named import.
Library declarations
Ramda
R.max(a, b)
Parameters
Parameter
Description
a
Required. Ord. First ordered value. One of a or b is returned. Not mutated.
b
Required. Ord. Second ordered value to compare against. Not mutated.
Return Value
Return Value
Description
Ord (same type as inputs)
The larger of a and b. Always one of the two inputs, never a Boolean.
Ramda Examples
📚 Getting Started
The official Ramda samples for numbers and strings.
Example 1 — Official Number and String Samples
Numbers and strings from the Ramda docs. R.max returns the larger value itself.
That is the docs sample from ramdajs.com. 789 is greater than 123, so 789 is returned. Strings compare lexicographically: 'b' > 'a', so 'b' is returned.
Example 2 — vs R.gt and R.gte on the Same Pair
Compare value pickers with Boolean tests on (789, 123). Highlight: R.max returns the value; R.gt and R.gte return true.
All three helpers agree that 789 is the larger side, but they answer different questions. R.max gives you the value to use downstream. R.gt and R.gte only tell you the ordering relationship holds.
📈 Practical Patterns
Reduce maximum, floor-at-zero with placeholder, then later Date selection.
Example 3 — Maximum of a List with R.reduce
Fold a list to its largest element. R.max is the combiner; -Infinity is the identity for numbers.
R.reduce walks the list left to right, keeping the running maximum. Each step compares the accumulator with the next element via R.max. The final accumulator is 7.
Example 4 — Floor Negatives with R.max(R.__, 0)
Fix the floor at zero with the placeholder. Each list element is compared against 0; the larger value is kept.
JavaScript coerces Dates to numbers when compared. June 2024 is later than January 2024, so the June Date object is returned. Use the result directly in pipelines that need the most recent timestamp.
Compatibility
Browser Support
R.max() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Ramda 0.1.0+ · Any JS runtime
Ramda.js R.max()
Load Ramda 0.1.0 or later via CDN or npm, then call R.max with two ordered values. No extra browser API is required.
100%With Ramda 0.1.0+
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
R.max()Universal
Bottom line: Safe in any project that includes Ramda 0.1.0 or later. Use a CDN build such as ramda.min.js in the browser or install ramda from npm for Node. These labs use [email protected].
Frequently Asked Questions
R.max(a, b) returns the larger of its two arguments — the value itself, not a Boolean. Type: Ord a => a → a → a. Arity 2, curried. Added in v0.1.0.
R.max(789, 123) returns 789. R.max('a', 'b') returns 'b'. The result is always one of the two inputs.
R.max returns the larger value. R.gt and R.gte return true or false about ordering. On (789, 123), R.max gives 789 while R.gt and R.gte give true.
R.min returns the smaller value. R.maxBy(fn, a, b) picks the larger by a computed key via fn. R.max compares the values directly.
Yes. Any ordered type that JavaScript can compare works — numbers, strings (lexicographic), and Dates (by time value). R.max picks the later or lexicographically greater value.
No. R.max is a stable Ramda relation helper from v0.1.0. It is not deprecated, experimental, or non-standard.