Ramda.js R.concat() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
List

Definition

R.concat(first, second) joins two lists into a new list, or two strings into a new string, with the items of first followed by the items of second (official Ramda docs). It never changes the inputs.

Stable since v0.1.0: R.concat is not deprecated, experimental, or non-standard. Note: unlike native Array.prototype.concat, both arguments must be the same type, or it throws a TypeError.

Syntax

Call R.concat. Start with this line.

Ramda
R.concat(a, b) or R.concat(a)(b)
CallWhat it does
R.concat(a, b) or R.concat(a)(b)Primary signature.
R.concat(...)Call the list helper.

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

Library declarations
Ramda
R.concat(a, b) or R.concat(a)(b)

Parameters

ParameterDescription
firstRequired. Array or string that comes first in the result
secondOptional. Same type as first; omit it to get a reusable function

Return Value

Return ValueDescription
*A new array or string; inputs are never changed

Ramda Examples

Example 1 — Official Join Two Lists

Join two arrays into one new array — the list samples from the Ramda docs.

Ramda
console.log(R.concat([4, 5, 6], [1, 2, 3]));  // [4, 5, 6, 1, 2, 3]
console.log(R.concat([], []));                // []
Try It Yourself

How It Works

  1. Type check. Both arguments are arrays, so Ramda can join them.
  2. Order. Items of the first list come first: 4, 5, 6, then 1, 2, 3.
  3. Not sorted. R.concat only joins; it never reorders items.
  4. Empty is fine. Two empty lists give a new empty list.

Example 2 — Official Strings and a Reusable Prefix

Join two strings, then use currying to build a greeting helper.

Ramda
console.log(R.concat('ABC', 'DEF'));  // 'ABCDEF'

const greet = R.concat('Hello, ');

console.log(greet('Ada'));            // 'Hello, Ada'
Try It Yourself

How It Works

  1. Strings. Both arguments are strings, so Ramda returns 'ABC' + 'DEF'.
  2. Curried. R.concat('Hello, ') fixes the first argument and returns a function.
  3. Second goes last. greet('Ada') supplies the second string, so it lands after the prefix.
  4. Reusable. greet can be passed to R.map to greet a whole list of names.

Example 3 — Add a Suffix Instead of a Prefix

A curried R.concat('!') prefixes. Flip the arguments or use a placeholder to add the text at the end.

Ramda
console.log(R.concat('!')('Hi'));         // '!Hi'  (prefix)

const exclaim = R.flip(R.concat)('!');
const shout = R.concat(R.__, '!');

console.log(exclaim('Hi'));               // 'Hi!'
console.log(shout('Hi'));                 // 'Hi!'
Try It Yourself

How It Works

  1. Left to right. R.concat('!') fills the first slot, so 'Hi' goes second → '!Hi'.
  2. Flip. R.flip swaps the first two arguments, so '!' becomes the second one.
  3. Placeholder. R.__ leaves the first slot open and fixes '!' in the second.
  4. Same result. Both helpers turn 'Hi' into 'Hi!'; pick whichever reads better to you.

Example 4 — Join Many Lists

R.concat joins two lists at a time; fold it over a list of lists, or use R.unnest.

Ramda
const lists = [[1, 2], [3], [4, 5]];

console.log(R.reduce(R.concat, [], lists));  // [1, 2, 3, 4, 5]
console.log(R.unnest(lists));                // [1, 2, 3, 4, 5]
Try It Yourself

How It Works

  1. Start empty. R.reduce begins with [].
  2. Fold. Each step runs R.concat(acc, next): [1, 2] → [1, 2, 3] → [1, 2, 3, 4, 5].
  3. Shortcut. R.unnest flattens one level and gives the same result in one call.
  4. Prefer unnest for big data. The fold copies the growing result every step; see Performance Notes.

Example 5 — The Same-Type Rule

Native concat mixes types; R.concat throws. Use R.append for a single item.

Ramda
console.log([1, 2].concat(3));     // [1, 2, 3]  native mixes types
console.log(R.append(3, [1, 2]));  // [1, 2, 3]  Ramda: add one item

try {
  R.concat([1, 2], 3);
} catch (err) {
  console.log(err.message);        // '3 is not an array'
}
Try It Yourself

How It Works

  1. Native is loose. Array.prototype.concat adds a non-array value as one item.
  2. Ramda is strict. R.concat sees an array and a number, so it throws a TypeError.
  3. Catch it. try...catch shows the message '3 is not an array' instead of crashing.
  4. Right tool. For one item, use R.append or wrap it: R.concat([1, 2], [3]).

Browser & Runtime Support

R.concat() is plain JavaScript inside Ramda 0.1.0+. Arrays use native Array.prototype.concat (ES3) and strings use +, so it works wherever Ramda loads.

✓ Ramda 0.1.0+ · Any JS runtime

Ramda.js R.concat()

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.

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.concat() 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].

Frequently Asked Questions

R.concat(first, second) joins two lists into a new list, or two strings into a new string. The official samples are R.concat([4, 5, 6], [1, 2, 3]), which returns [4, 5, 6, 1, 2, 3], and R.concat('ABC', 'DEF'), which returns 'ABCDEF'.
Native concat accepts any values, so [1, 2].concat(3) returns [1, 2, 3]. R.concat requires both arguments to be the same type and throws a TypeError such as '3 is not an array' otherwise. R.concat also takes exactly two arguments and is curried.
Currying fills arguments from the left, so R.concat('!') fixes the first argument and the value you pass later goes second. To add a suffix, use R.flip(R.concat)('!') or R.concat(R.__, '!'), which both turn 'Hi' into 'Hi!'.
R.append adds one item to the end of a list. R.concat joins two whole lists. To add a single value with R.concat, wrap it in an array first: R.concat([1, 2], [3]).
No. It always returns a new array or string. The copy is shallow, so objects and nested arrays inside the result are the same references as in the inputs.
No. R.concat has been a stable Ramda list function since v0.1.0. It is not deprecated, experimental, or non-standard.

Next: R.count()

Count how many items in a list match a predicate.

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