Ramda.js R.append() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
List

Definition

R.append(el, list) returns a new array with el added at the end (official Ramda docs). It is the immutable version of array.push — the same result as [...list, el] with the spread operator, but curried so it fits Ramda pipelines.

Stable since v0.1.0: R.append is one of Ramda’s original list functions. It is not deprecated, experimental, or non-standard.

Syntax

Call R.append. Start with this line.

Ramda
R.append(el, list) or R.append(el)(list)
CallWhat it does
R.append(el, list) or R.append(el)(list)Primary signature.
R.append(...)Call the list helper.

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

Library declarations
Ramda
R.append(el, list) or R.append(el)(list)

Parameters

ParameterDescription
elRequired. Any value — added as one item, even if it is an array
listRequired. Array (or array-like) to copy — never changed

Return Value

Return ValueDescription
*A new array, one item longer than list

Ramda Examples

Example 1 — Official Samples

Add a string, add to an empty list, and add an array — the three samples from the Ramda docs.

Ramda
console.log(R.append('tests', ['write', 'more']));   // ['write', 'more', 'tests']
console.log(R.append('tests', []));                  // ['tests']
console.log(R.append(['tests'], ['write', 'more'])); // ['write', 'more', ['tests']]
Try It Yourself

How It Works

  1. Copy, then add. R.append copies ['write', 'more'] and puts 'tests' at the end.
  2. Empty list. There is nothing to copy, so the result holds only 'tests'.
  3. Array as an item. ['tests'] is added whole, so the last item is itself an array.
  4. Same length rule. Every call returns exactly one more item than the input list.

Example 2 — The Original List Stays Untouched

Unlike push, R.append gives you a new array and leaves the old one alone.

Ramda
const tasks = ['write', 'more'];
const next = R.append('tests', tasks);

console.log(next);          // ['write', 'more', 'tests']
console.log(tasks);         // ['write', 'more']
console.log(next === tasks); // false
Try It Yourself

How It Works

  1. New array. next holds the copy with 'tests' at the end.
  2. Input preserved. tasks still has only two items.
  3. Different reference. next === tasks is false, which helps UI libraries detect the change.
  4. Compare with push. tasks.push('tests') would change tasks and return 3, not an array.

Example 3 — append vs prepend vs concat

Three ways to grow a list: one item at the end, one item at the start, or many items at once.

Ramda
const list = ['write', 'more'];

console.log(R.append('tests', list));            // ['write', 'more', 'tests']
console.log(R.prepend('tests', list));           // ['tests', 'write', 'more']
console.log(R.concat(list, ['tests', 'docs']));  // ['write', 'more', 'tests', 'docs']
Try It Yourself

How It Works

  1. append. Puts the single item last.
  2. prepend. R.prepend takes the same arguments but puts the item first.
  3. concat. R.concat joins two lists, so 'tests' and 'docs' become two separate items.
  4. Argument order. append and prepend take the item first; concat takes the first list first.

Example 4 — Curried Steps in a Pipeline

Leave out the list to get reusable steps, then chain them with R.pipe.

Ramda
const addSteps = R.pipe(
  R.append('build'),
  R.append('test')
);

console.log(addSteps(['lint'])); // ['lint', 'build', 'test']
console.log(addSteps([]));       // ['build', 'test']
Try It Yourself

How It Works

  1. Curry. R.append('build') has no list yet, so it returns a function waiting for one.
  2. Chain. R.pipe runs the steps left to right: add 'build', then 'test'.
  3. Order kept. Each step appends to the result of the previous one, so 'test' ends up last.
  4. Reusable. addSteps works on any list, including an empty one.

Example 5 — Add to an Array Inside an Object

Add an item to a cart without touching the original object, using R.evolve.

Ramda
const cart = { owner: 'Ada', items: ['bread'] };

const updated = R.evolve({ items: R.append('milk') }, cart);

console.log(updated);    // { owner: 'Ada', items: ['bread', 'milk'] }
console.log(cart.items); // ['bread']
Try It Yourself

How It Works

  1. Describe the change. R.evolve takes an object of functions keyed by property name.
  2. Curried append. R.append('milk') is the function that transforms items.
  3. New object. evolve returns a copy with the new items array; owner is carried over.
  4. Original safe. cart.items is still ['bread'] — the pattern used for Redux-style state updates.

Browser & Runtime Support

R.append() is plain JavaScript inside Ramda (available since v0.1.0). It uses no browser API, so support depends only on loading Ramda.

✓ Ramda 0.1.0+ · Any JS runtime

Ramda.js R.append()

The UMD build (ramda.min.js) is compiled to ES5 syntax, so it runs in Chrome, Firefox, Safari, and Edge. Via npm it works in Node.js, Deno, and Bun with require or import. No modern syntax is needed to call R.append itself.

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.append() Universal

Bottom line: Safe in any project that includes Ramda. Load ramda.min.js from a CDN in the browser, or npm install ramda for Node, Deno, and Bun. These labs load [email protected] from jsDelivr.

Frequently Asked Questions

R.append(el, list) returns a new array with el added at the end. The original list is not changed. Official sample: R.append('tests', ['write', 'more']) returns ['write', 'more', 'tests'].
No. It copies the list into a new array and adds the item to the copy. Native array.push changes the array in place and returns the new length; R.append returns the new array.
R.append adds one item at the end. R.prepend adds one item at the start. R.concat joins two lists into one. Use concat when you want to add several items at once.
The array becomes a single last item, so the result is nested: R.append(['tests'], ['write', 'more']) returns ['write', 'more', ['tests']]. Use R.concat(list, ['tests']) to add the items themselves.
Ramda treats a missing list as an empty one, so R.append(1, null) returns [1] instead of throwing. That is convenient, but it can also hide a bug where the list was never loaded.
No. R.append has been a stable Ramda list function since v0.1.0. It is not deprecated, experimental, or non-standard.

Next: R.chain()

Map a function that returns lists, then flatten the result one level.

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

6 people found this page helpful