Ramda.js R.tail() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
List

Definition

R.tail(list) returns every item except the first — a new array for arrays and a new string for strings (official Ramda docs). It is the partner of R.head: head gives the first item, tail gives the rest.

Stable since v0.1.0: R.tail is not deprecated, experimental, or non-standard. The native equivalents are Array.prototype.slice(1) and String.prototype.slice(1).

Syntax

Call R.tail. Start with this line.

Ramda
R.tail(list)
CallWhat it does
R.tail(list)Primary signature.
R.tail(...)Call the list helper.

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

Library declarations
Ramda
R.tail(list)

Parameters

ParameterDescription
listRequired. Array or String. The value to copy without its first item

Return Value

Return ValueDescription
*Array → new array, string → new string

Ramda Examples

Example 1 — Lists and Strings (Official Samples)

Drop the first item of an array or the first character of a string.

Ramda
console.log(R.tail([1, 2, 3])); // [2, 3]
console.log(R.tail([1]));       // []
console.log(R.tail('abc'));     // 'bc'
console.log(R.tail(''));        // ''
Try It Yourself

How It Works

  1. Array. The first item 1 is skipped, so [2, 3] remains.
  2. One item. Removing the only item leaves an empty array, not undefined.
  3. String. For text, the first character goes and a string comes back: 'bc'.
  4. Empty. There is nothing to remove, so '' stays '' without an error.

Example 2 — Skip a CSV Header Row

Keep the data rows and leave the original lines untouched.

Ramda
const rows = ['name,age', 'Ada,36', 'Alan,41'];

console.log(R.tail(rows)); // ['Ada,36', 'Alan,41']
console.log(rows.length);  // 3
Try It Yourself

How It Works

  1. Header first. Line 0 holds the column names 'name,age'.
  2. Drop it. R.tail(rows) returns only the data lines.
  3. No mutation. rows.length is still 3 — unlike shift(), which would change it to 2.
  4. Next step. The result is ready for R.map to parse each row.

Example 3 — Split a Command into Head and Tail

The first word is the command; the rest are its arguments.

Ramda
const words = 'deploy staging --force'.split(' ');

console.log(R.head(words)); // 'deploy'
console.log(R.tail(words)); // ['staging', '--force']
Try It Yourself

How It Works

  1. Split. split(' ') turns the text into ['deploy', 'staging', '--force'].
  2. Head. R.head returns the first word, the command name.
  3. Tail. R.tail returns the remaining words, the arguments.
  4. Together. head + tail always cover the whole list.

Example 4 — Differences Between Neighbours

Line up each value with the next one by pairing the list with its tail.

Ramda
const temps = [20, 22, 21, 25];

const diffs = R.zipWith(R.subtract, R.tail(temps), temps);

console.log(diffs); // [2, -1, 4]
Try It Yourself

How It Works

  1. Shift by one. R.tail(temps) is [22, 21, 25] — each value’s “next” reading.
  2. Pair up. R.zipWith pairs 22–20, 21–22, 25–21 and stops at the shorter list.
  3. Subtract. R.subtract computes next minus current for each pair.
  4. Result. Three changes for four readings: up 2, down 1, up 4.

Example 5 — Recursive Sum with Head and Tail

The classic functional pattern: handle the first item, then recurse on the rest.

Ramda
const sum = (xs) => R.isEmpty(xs) ? 0 : R.head(xs) + sum(R.tail(xs));

console.log(sum([1, 2, 3, 4])); // 10
console.log(sum([]));           // 0
Try It Yourself

How It Works

  1. Base case. R.isEmpty stops the recursion: an empty list sums to 0.
  2. Split. Otherwise take the first number with R.head and the rest with R.tail.
  3. Recurse. 1 + sum([2, 3, 4]) → 1 + 2 + sum([3, 4]) → … → 10.
  4. Learning only. Each step copies the list, so for real code use R.sum (see Performance Notes).

Browser & Runtime Support

R.tail() is plain JavaScript inside Ramda and has existed since v0.1.0. It uses only slice, so support depends only on loading Ramda.

✓ Ramda 0.1.0+ · Any JS runtime

Ramda.js R.tail()

The UMD build (ramda.min.js) uses ES5 syntax, so it runs in every modern browser. 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 End of life · ES5 build may load, untested
Legacy only
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Node.js Supported · npm install ramda
Supported
Deno Supported · npm:ramda
Supported
Bun Supported · bun add ramda
Supported
R.tail() Universal

Bottom line: Safe in any project that loads Ramda. Use ramda.min.js from a CDN in the browser, or npm install ramda for Node, Deno, and Bun. The Try-it labs load [email protected] and use modern syntax (const, arrow functions).

Frequently Asked Questions

A new list or string with every item except the first. R.tail([1, 2, 3]) returns [2, 3] and R.tail('abc') returns 'bc'. The original value is not changed.
An empty result, never an error. R.tail([]) is [] and R.tail('') is ''. A one-item list also gives [].
shift() removes the first item from the original array and returns that item. R.tail returns a new array of the remaining items and leaves the original alone.
Yes, for arrays and strings the result is the same. R.tail is shorter and reads well next to R.head; R.drop(n) is the general version for skipping any number of items.
R.head returns the first item. R.init returns every item except the last, and R.last returns the last item.
No. R.tail has been part of Ramda since v0.1.0 and is stable. It is not deprecated, experimental, or non-standard.

Next: R.take()

Keep only the first n items of a list or string.

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