Ramda.js R.call() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

Returns the result of calling its first argument with the remaining arguments (official Ramda docs). Think of it as fn(a, b, c) with the function written first — handy when the function is dynamic, or as a converging function for R.converge.

Stable since v0.9.0: R.call is a core Ramda helper — not deprecated, experimental, or non-standard. It takes the function first and does not set this (unlike native Function.prototype.call). For array args, use R.apply.

Syntax

Call R.call. Start with this line.

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

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

Library declarations
Ramda
R.call(fn, ...args)

Parameters

ParameterDescription
fnRequired. Function to apply to the remaining arguments
argsOptional. Any number of positional arguments

Return Value

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

Ramda Examples

Example 1 — Official R.add

Call a function with two numbers — the sample from the Ramda docs.

Ramda
console.log(R.call(R.add, 1, 2)); // 3
Try It Yourself

How It Works

  1. Function first. R.add is argument 1 to R.call.
  2. Remaining args. 1 and 2 are forwarded to R.add.
  3. Result. Same as R.add(1, 2) → 3.
  4. Why bother. The function can be a variable, a lookup, or a converge branch.

Example 2 — R.call vs R.apply

Same Math.max result — loose args vs an array.

Ramda
console.log(R.call(Math.max, 1, 2, 3));    // 3
console.log(R.apply(Math.max, [1, 2, 3])); // 3
Try It Yourself

How It Works

  1. call. Arguments are listed after the function.
  2. apply. Arguments live in one array — useful after map / spread-style data.
  3. Same outcome. Both return the max value 3.
  4. Pick by shape. Separate values → call; list → apply.

Example 3 — vs Function.prototype.call

Same name, different job — native sets this; Ramda does not.

Ramda
console.log(Math.max.call(null, 1, 2, 3)); // 3  (thisArg first)
console.log(R.call(Math.max, 1, 2, 3));    // 3  (function first)
Try It Yourself

How It Works

  1. Native. fn.call(thisArg, …args) — first parameter is the receiver.
  2. Ramda. R.call(fn, …args) — first parameter is the function.
  3. Here both work. Math.max ignores this, so results match.
  4. Need this? Use native call/apply or R.bind.

Example 4 — Official converge Indent Formatter

First branch builds a replacer function; second supplies the string — R.call connects them.

Ramda
const indentN = R.pipe(
  R.repeat(' '),
  R.join(''),
  R.replace(/^(?!$)/gm)
);

const format = R.converge(R.call, [
  R.pipe(R.prop('indent'), indentN),
  R.prop('value')
]);

console.log(format({ indent: 2, value: 'foo\nbar\nbaz\n' }));
// "  foo\n  bar\n  baz\n"
Try It Yourself

How It Works

  1. indentN. Turns a count into a partial replace that prefixes non-empty lines.
  2. Branch 1. Reads indent → produces that replacer function.
  3. Branch 2. Reads value → the multiline string.
  4. R.call. Invokes the replacer with the string → indented output.

Example 5 — Call a Function from a Table

Look up an operation, then invoke it with R.call.

Ramda
const ops = {
  add: R.add,
  multiply: R.multiply
};

console.log(R.call(ops.add, 2, 3));      // 5
console.log(R.call(ops.multiply, 2, 3)); // 6
Try It Yourself

How It Works

  1. Table lookup. ops.add / ops.multiply are functions stored by name.
  2. call runs them. Arguments follow after the chosen function.
  3. Results. 2 + 3 → 5, 2 × 3 → 6.
  4. Pattern. Useful when the operation name is data (config, UI choice, message type).

Browser & Runtime Support

R.call() is ordinary JavaScript once Ramda is loaded. It needs no special browser API — only a JS runtime that can run Ramda (v0.9.0+).

✓ Ramda 0.9.0+ · Any JS runtime

Ramda.js R.call()

Works in every modern browser and runtime where you can load Ramda (CDN or npm). Internet Explorer needs a build that targets that environment; there is no native IE API to polyfill.

100% With Ramda loaded
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.call() Universal

Bottom line: Safe in any project that includes Ramda 0.9.0 or later. Load ramda.min.js from a CDN in the browser, or npm install ramda for Node, Bun, and Deno.

Frequently Asked Questions

R.call(fn, ...args) runs fn with the remaining arguments and returns the result. It is fn(a, b, c) written with the function first. The docs sample is R.call(R.add, 1, 2) which returns 3.
R.call(R.add, 1, 2); //=> 3. The docs also use R.call as the converging function in R.converge so the first branch can produce a function and the other branches produce its arguments. Added in v0.9.0. See also R.apply.
R.call(fn, a, b, c) passes arguments one by one. R.apply(fn, [a, b, c]) passes the same arguments from an array. Use call when you already have separate values; use apply when they live in a list.
Native fn.call(thisArg, a, b) sets this first, then the arguments. R.call(fn, a, b) takes the function first and does not take a thisArg. They share a name and solve different jobs.
converge calls one function with the results of several branches. If the first branch returns a function and the rest return values, R.call is the combiner: it invokes that function with those values. The official indent formatter is that pattern.
No. R.call is a stable Ramda function helper from v0.9.0. It is not deprecated, experimental, or non-standard.

Next: R.comparator()

Turn a less-than predicate into a −1 / 0 / 1 sort comparator.

R.comparator() 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.

12 people found this page helpful