Ramda.js R.apply() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

Calls a function with an array of arguments spread as separate parameters — equivalent to fn(...args). Handy for turning a variadic function into a fixed-arity step that accepts a list. Part of Ramda Function since v0.7.0 (stable — not deprecated).

Note: If this matters, bind the function first (R.bind or fn.bind(ctx)). See also R.call and R.unapply.

Syntax

Call R.apply. Start with this line.

Ramda
R.apply(fn, args) or R.apply(fn)(args)
CallWhat it does
R.apply(fn, args) or R.apply(fn)(args)Primary signature.
R.apply(...)Call the function helper.

Prefer import { apply } from "ramda" when you want a named import.

Library declarations
Ramda
R.apply(fn, args) or R.apply(fn)(args)

Parameters

ParameterDescription
fnRequired. Function to call with the spread arguments
argsRequired. Array of arguments for fn

Return Value

Return ValueDescription
*Whatever fn(...args) returns

Ramda Examples

Example 1 — Official Math.max

Spread a number list into Math.max to find the largest value.

Ramda
const nums = [1, 2, 3, -99, 42, 6, 7];

R.apply(Math.max, nums);
// → 42
Try It Yourself

How It Works

  1. Start with a list. Seven numbers, including a negative and 42.
  2. Spread. R.apply calls Math.max(1, 2, 3, -99, 42, 6, 7).
  3. Result. The largest value is 42.
  4. Why apply. Variadic helpers need separate args, not one array.

Example 2 — Array vs Spread

Passing the array itself to Math.max fails; R.apply succeeds.

Ramda
const nums = [1, 2, 3, -99, 42, 6, 7];

Math.max(nums);            // → NaN
R.apply(Math.max, nums);   // → 42
Try It Yourself

How It Works

  1. Bare call. Math.max(nums) receives one argument: the array.
  2. Not a number. Coercion fails → NaN.
  3. Apply spreads. Each list item becomes its own argument.
  4. Rule. List in hand + variadic fn → use R.apply.

Example 3 — Math.min

Same pattern for the smallest value.

Ramda
const nums = [1, 2, 3, -99, 42, 6, 7];

R.apply(Math.min, nums);
// → -99
Try It Yourself

How It Works

  1. Same list. Includes -99 as the lowest value.
  2. Spread into min. Math.min(1, 2, 3, -99, …).
  3. Result. Returns -99.
  4. Pair with max. R.apply(Math.max, nums) / R.apply(Math.min, nums).

Example 4 — Custom Two-Argument Function

Call any multi-arg function when the values already live in an array.

Ramda
function greet(name, city) {
  return name + " from " + city;
}

R.apply(greet, ["Ada", "London"]);
// → "Ada from London"
Try It Yourself

How It Works

  1. Define. greet expects name and city.
  2. Pack args. ["Ada", "London"] holds both values.
  3. Apply. Becomes greet("Ada", "London").
  4. Use case. Useful when a previous step returns an args array.

Example 5 — Pipe: Max of Positives

Filter first, then spread the remaining numbers into Math.max.

Ramda
const maxPositive = R.pipe(
  R.filter((n) => n > 0),
  R.apply(Math.max)
);

maxPositive([-5, 10, 3, -2, 8]);
// → 10
Try It Yourself

How It Works

  1. Filter. Keeps [10, 3, 8].
  2. Curried apply. R.apply(Math.max) waits for that list.
  3. Spread. Math.max(10, 3, 8) → 10.
  4. Pipe fit. Docs note this pattern turns variadic fns into list-friendly steps.

Browser & Runtime Support

R.apply is a Ramda Function helper since v0.7.0. It runs anywhere Ramda runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install ramda.

✓ Stable · Ramda 0.7.0+

R.apply()

Available in full Ramda builds from v0.7.0 onward. Works in evergreen browsers and current Node LTS when Ramda is loaded.

100% With Ramda 0.7+
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
R.apply Ramda 0.7.0+

Bottom line: Safe for production once Ramda is loaded. Ideal for Math.max / Math.min and other variadic APIs that need a list spread. Official reference: ramdajs.com/docs/#apply.

Frequently Asked Questions

R.apply(fn, args) calls fn with the values in the args array as separate arguments. It is equivalent to fn(...args). Official: R.apply(Math.max, [1, 2, 3, -99, 42, 6, 7]) → 42.

Next: R.applySpec()

Turn a spec of functions into one function that builds a matching object.

R.applySpec() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful