Lodash _.tail() method

Beginner
⏱️ 5 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.tail(array) yields every element except index 0.
  • Why empty and single-element inputs collapse to [].
  • How tail compares with _.slice(), _.drop(), and _.initial().
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

_.head() grabs the first element—tail intentionally mirrors it by returning the complementary suffix.

  • You understand shallow copies: nested objects inside the tail still alias the originals.
  • You can open Try-it labs or run snippets locally.

Overview

_.tail trims exactly one leading slot—ideal for recursive walks, queue drains, or stripping command tokens while leaving operands intact.

Drop the head

Always skips index zero—no numeric arity to remember unlike configurable drops.

Array-like friendly

Collections exposing numeric keys plus length coerce just like other Lodash slice helpers.

Non-destructive

Original ordering and references remain untouched for downstream observers.

Syntax

javascript
_.tail(array)
  • array: dense collection or array-like value.
  • Returns: new array containing elements from index 1 through length - 1.
1

Everything after the first

The leading element disappears while interior order stays unchanged.

javascript
import tail from "lodash/tail";

tail(["north", "east", "south", "west"]);
// → ["east", "south", "west"]
Try it Yourself
2

Empty or singleton

No trailing segment exists once the collection has zero or one slot.

javascript
import tail from "lodash/tail";

tail([]);
tail([42]);
// both → []
Try it Yourself
3

Array-like object

Numeric indices plus length behave like arguments snapshots without manually spreading.

javascript
import tail from "lodash/tail";

const like = { 0: "a", 1: "b", 2: "c", length: 3 };

tail(like);
// → ["b", "c"]
Try it Yourself

📋 _.tail vs _.slice, _.drop, _.initial

APIWhat it removesMental model
_.tail(array)First element onlySuffix starting at index 1
_.slice(array, 1)Everything before index 1General window—tail is the readable preset
_.drop(array, n)First n elementsUse n = 1 to mirror tail
_.initial(array)Last elementOpposite edge—prefix instead of suffix

Pitfalls to avoid

Deep

Shallow tail

Nested structures inside tail slots refer to the same objects as the parent collection.

Edge

Expecting undefined

Unlike head, tail never returns undefined—it returns [] when nothing follows.

Mix

Confusion with initial

initial trims the final element; combine carefully when piping both ends.

❓ FAQ

No. Lodash returns a new array containing elements from index 1 onward (internally aligned with slice semantics).
Both produce an empty array: there is nothing after the first slot—or there is no first slot at all.
Yes for typical Lodash collections—the helper is the readable shortcut for that slice.
_.drop(array, 1) trims one element from the head as well; tail is the fixed arity version.
Use import tail from "lodash/tail" or require("lodash/tail") for tree-shaking friendly bundles.

Summary

Did you know?

_.tail is the list “cdr” to _.head()’s “car”: split once, process the leader, then recurse or pipe the remainder through _.drop()-friendly pipelines.

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