Lodash _.dropRight() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Creates a slice of array with n elements dropped from the end. Part of Lodash 4.x Array — stable and non-mutating.

Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.

Syntax

Call _.dropRight on an array. Start with this line.

Lodash
_.dropRight(array, [n=1])
CallWhat it does
_.dropRight(array, [n=1])Primary signature.
_.dropRight(array)Call with an array argument.

Prefer import dropRight from "lodash/dropRight" when you want a smaller bundle.

Library declarations
Lodash
_.dropRight(array, [n=1])

Parameters

ParameterDescription
arrayRequired. Source to query
nOptional. Count to drop from the end; default 1

Return Value

Return ValueDescription
*New array of remaining elements

Lodash Examples

Example 1 — Official: Default Drop One from End

Omit n and Lodash removes the last element.

Lodash
_.dropRight([1, 2, 3]);
// → [1, 2]
Try It Yourself

How It Works

  1. Source. Array [1, 2, 3]; indexes 0 … 2.
  2. Default. Missing n means drop 1 item from the end.
  3. Skip tail. Remove 3; keep 1 and 2.
  4. New array. Result is [1, 2]; the original is untouched.

Example 2 — Official: Drop a Specific Count from End

Pass n to skip several trailing values in one call.

Lodash
_.dropRight([1, 2, 3], 2);
// → [1]
Try It Yourself

How It Works

  1. Ask for 2. Drop the last two slots.
  2. Removed. 2 and 3 leave the result.
  3. Kept. Only 1 remains → [1].
  4. Same as slice. Equivalent to [1, 2, 3].slice(0, 1).

Example 3 — Official: n Larger Than Length

Dropping more items than exist yields an empty array.

Lodash
_.dropRight([1, 2, 3], 5);
// → []
Try It Yourself

How It Works

  1. Ask for 5. Source only has 3 items.
  2. Everything skipped. End index clamps to 0.
  3. Result. Empty array [].
  4. Safe. No throw — check result.length if you need a guard.

Example 4 — Official: Drop Zero

n = 0 keeps the whole sequence in a new array.

Lodash
_.dropRight([1, 2, 3], 0);
// → [1, 2, 3]
Try It Yourself

How It Works

  1. Count is 0. Nothing is removed from the end.
  2. Still a copy. You get a new array with the same values.
  3. Order preserved. [1, 2, 3] in the same order.
  4. Use. Handy when n comes from a variable that may be zero.

Example 5 — Empty Array

Dropping from an empty source stays empty.

Lodash
_.dropRight([], 2);
// → []
Try It Yourself

How It Works

  1. Empty source. No elements to keep or drop.
  2. Result. Lodash returns [].
  3. Safe. No throw — fine in pipelines that may receive empty lists.
  4. Guard. Check length before assuming leftover items exist.

Browser & Runtime Support

_.dropRight is a Lodash 4.x Array helper. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 4.x

_.dropRight()

Available in [email protected] full builds and the lodash/dropRight modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
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
_.dropRight Lodash 4.x+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import dropRight from "lodash/dropRight" for smaller builds. Not a native browser API — load Lodash first.

Frequently Asked Questions

_.dropRight(array, n) creates a new array with the last n elements removed from the end. The default for n is 1. The source array is not mutated.
No. Lodash returns a new array (a slice of the remaining elements). The input stays unchanged.
When n is omitted, Lodash drops one element from the end — the same “all but last” case as _.initial on a normal array.
You get an empty array []. Nothing throws.
Nothing is dropped. You get a new array with every element (shallow copy, like slice of the whole array).
Use import dropRight from "lodash/dropRight" or require("lodash/dropRight") so bundlers can tree-shake. Full build: import _ from "lodash" then _.dropRight.

Next: _.dropRightWhile()

Trim a trailing run with a predicate instead of a fixed count.

_.dropRightWhile() 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.

10 people found this page helpful