Ramda.js R.always() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

R.always(val) returns a function that always returns val, no matter what arguments you pass. Handy when an API needs a function, but you want a fixed answer.

Stable: R.always has been in Ramda since v0.1.0. It is not deprecated, experimental, or non-standard. Also known as const, constant, or the K combinator.

Syntax

Call R.always. Start with this line.

Ramda
R.always(val)
CallWhat it does
R.always(val)Primary signature.
R.always(...)Call the function helper.

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

Library declarations
Ramda
R.always(val)

Parameters

ParameterDescription
valRequired. Value to wrap (any type)
Arguments to the resultOptional. Accepted and ignored

Return Value

Return ValueDescription
*Function (* → val) that ignores args

Ramda Examples

Example 1 — Official Tee Helper

Build a function that always returns the string 'Tee'.

Ramda
const t = R.always('Tee');

console.log(t());
// → 'Tee'

console.log(t());
// → 'Tee'
Try It Yourself

How It Works

  1. Wrap. R.always('Tee') returns a new function t.
  2. Call. t() returns the closed-over string.
  3. Repeat. Every call yields the same 'Tee'.
  4. Name. Other libraries call this constant or the K combinator.

Example 2 — Arguments Are Ignored

Extra arguments never change the wrapped value.

Ramda
const t = R.always('Tee');

console.log(t());
// → 'Tee'

console.log(t(1, 2, 3));
// → 'Tee'

console.log(t('nope'));
// → 'Tee'
Try It Yourself

How It Works

  1. Zero args. Still returns 'Tee'.
  2. Many args. 1, 2, 3 are accepted and discarded.
  3. Wrong string. Passing 'nope' does not replace the wrap.
  4. Rule. The value was fixed when you called R.always.

Example 3 — Map a Constant

Replace every list item with the same value.

Ramda
console.log(R.map(R.always(0), [1, 2, 3]));
// → [0, 0, 0]

console.log(R.map(R.always(true), ['a', 'b']));
// → [true, true]
Try It Yourself

How It Works

  1. Pass by reference. R.map needs a function — give it R.always(0).
  2. Per item. Each element is ignored; the callback returns 0.
  3. Result. A new list filled with that constant.
  4. Same idea. R.always(true) builds a boolean flag list.

Example 4 — Constant ifElse Branches

Return a fixed string from each branch of R.ifElse.

Ramda
const label = R.ifElse(
  R.equals(0),
  R.always('zero'),
  R.always('other')
);

console.log(label(0));
// → 'zero'

console.log(label(5));
// → 'other'
Try It Yourself

How It Works

  1. Predicate. R.equals(0) decides the branch.
  2. Then. On match, R.always('zero') returns the label.
  3. Else. Otherwise R.always('other') runs.
  4. Why. ifElse needs functions for both branches — always supplies constants cleanly.

Example 5 — Objects Are the Same Reference

Non-primitives come back as the original object — not a clone.

Ramda
const obj = { n: 1 };
const getObj = R.always(obj);

getObj().n = 99;

console.log(obj);
// → { n: 99 }

console.log(getObj());
// → { n: 99 }

console.log(getObj() === obj);
// → true
Try It Yourself

How It Works

  1. Wrap the object. getObj closes over obj.
  2. Mutate via the helper. getObj().n = 99 changes the original.
  3. Same memory. Later calls still return that object.
  4. Docs note. For non-primitives, the value is a reference — clone yourself if you need a copy.

Browser & Runtime Support

R.always is a Ramda Function helper since v0.1.0. It is plain JavaScript — no special browser API. It runs anywhere Ramda loads (CDN, npm, bundler).

✓ Stable · Ramda 0.1.0+

R.always()

Available in every Ramda full build since the earliest releases. Works in evergreen browsers and current Node LTS / Bun / Deno when Ramda is installed.

100% With Ramda 0.1+
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.always Ramda 0.1.0+

Bottom line: Safe for production once Ramda is loaded. Use a CDN build such as ramda.min.js in the browser, or npm install ramda for Node. No polyfill is needed beyond shipping Ramda itself.

Frequently Asked Questions

R.always(val) returns a new function that ignores every argument and always returns val. The docs sample is const t = R.always('Tee'); then t() is 'Tee'.
const t = R.always('Tee'); t(); //=> 'Tee'. Added in v0.1.0. In other languages this idea is called const, constant, or the K combinator.
No. For non-primitives the returned function gives back a reference to the original value. If you mutate that object, every later call sees the mutation.
R.identity(x) returns x — it uses the argument. R.always(val)(x) returns val — it ignores the argument. Use identity to pass a value through; use always to replace whatever arrives.
R.T is a function that always returns true (like R.always(true)). R.F always returns false (like R.always(false)). They are handy predicates in ifElse, filter, and cond.
No. R.always is a stable Ramda Function helper from v0.1.0. It is not deprecated, experimental, or non-standard.

About the author

Next: R.andThen()

Compose a callback that runs after a promise fulfills — Ramda’s then helper.

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