Lodash Wrapper .reverse() Method

Beginner
⏱️ 7 min read
📚 Updated: Jul 2026
🎯 6 Examples + 3 Try It
Seq & chaining

What You’ll Learn

By the end of this tutorial, you’ll use wrapper .reverse() to flip array order inside Lodash chains—and avoid surprises from in-place mutation.

01

In-place flip

.reverse()

02

Chain friendly

map then reverse.

03

Mutates source

Know the risk.

04

Immutable copy

slice / spread.

05

vs native

Same behavior.

06

Unwrap

End with .value().

What Is Wrapper .reverse()?

Wrapper .reverse() reverses the order of elements in the wrapped array in place and returns the wrapper so you can keep chaining. It behaves like native Array.prototype.reverse(), but fits naturally into Lodash pipelines built with _(value) or .chain().

💡
Not _.prototype.reverse()

There is no _.prototype.reverse() function. Call .reverse() on a wrapper: _( [1, 2, 3] ).reverse().value() returns [3, 2, 1] and mutates the original array.

Because .reverse() mutates the underlying array, always think about whether the source data should change. When you need a reversed copy without touching the original, wrap a shallow copy first—then finish with .value() to unwrap.

📝 Syntax

Call .reverse() on a wrapper with no arguments:

javascript
const array = [1, 2, 3];
const reversed = _(array).reverse().value();
// reversed -> [3, 2, 1]
// array also -> [3, 2, 1] (mutated)

Syntax Rules

  • No arguments — reverses the wrapped array in place.
  • Returns a wrapper — chain more steps or call .value() to unwrap.
  • Mutates underlying data — the original array variable sees the reversed order.
  • Chain position mattersmap then reverse reverses mapped values, not the pre-map source.
  • Immutable option — wrap array.slice() or [...array] before reversing.
javascript
import _ from "lodash";

const array = [1, 2, 3];
const reversedArray = _(array).reverse().value();

console.log(reversedArray);
// -> [3, 2, 1]

console.log(array);
// -> [3, 2, 1]

⚡ Quick Reference

TaskCode patternResult
Reverse in chain_(arr).reverse().value()Mutated + reversed
Map then reverse_(arr).map(fn).reverse().value()Transformed then flipped
Keep original safe_(arr.slice()).reverse().value()Source unchanged
Filter + reverse_(arr).filter(fn).reverse().value()Subset reversed
Unwrap result.value()See .value()
Flush mutation mid-chain.commit()See .commit()
Reverse
.reverse()

Flip order in place

Unwrap
.value()

Get plain array

Safe copy
arr.slice()

Before wrapping

🧰 Parameters

Wrapper .reverse() takes no arguments and returns a wrapper:

(no args) Required

Reverse the wrapped array in place. Same semantics as native Array.prototype.reverse().

_(array).reverse()
return Wrapper

Returns the wrapper for further chaining. Call .value() when you need a plain array.

_(arr).reverse().value()
mutation In place

The underlying array is modified. Any other reference to that array sees the new order.

array === reversed // true
deferred flush Optional

Some mutating wrapper steps may defer until .commit() or .value()—see the commit tutorial for details.

_(arr).reverse().commit()

Wrapper .reverse() is a mutating chain step—prefer copying first when immutability matters in your app.

Examples Gallery

Practical wrapper .reverse() patterns with sample output and interactive Try It Yourself labs.

📚 Getting Started

Reverse a wrapped array and see how in-place mutation affects the original variable.

Example 1 — Basic in-place reverse

Flip [1, 2, 3] and notice the original array changes too.

javascript
const array = [1, 2, 3];
const reversedArray = _(array).reverse().value();

console.log(reversedArray);
// -> [3, 2, 1]

console.log(array);
// -> [3, 2, 1]
Try It Yourself

How It Works

reversedArray and array refer to the same underlying array object—wrapper .reverse() mutates it in place.

Example 2 — Reverse without mutating the original

Wrap a shallow copy so the source array stays in its original order.

javascript
const originalArray = [1, 2, 3];
const reversedArray = _(originalArray.slice())
  .reverse()
  .value();

console.log(reversedArray);
// -> [3, 2, 1]

console.log(originalArray);
// -> [1, 2, 3]
Try It Yourself

📈 Practical Patterns

Combine reverse with transforms and build expressive chained pipelines.

Example 3 — Map, then reverse

Double each value, then flip the order of the transformed results.

javascript
const array = [1, 2, 3, 4, 5];
const modifiedArray = _(array)
  .map(function (value) { return value * 2; })
  .reverse()
  .value();

console.log(modifiedArray);
// -> [10, 8, 6, 4, 2]
Try It Yourself

Example 4 — Filter, then reverse

Keep values greater than 5, then present them in descending visual order.

javascript
const numbers = [1, 2, 3, 4, 5];
const transformedData = _(numbers)
  .map(function (value) { return value * 2; })
  .filter(function (value) { return value > 5; })
  .reverse()
  .value();

console.log(transformedData);
// -> [10, 8, 6]

🚀 Beyond the Basics

Compare with native reverse and know when copying is the safer choice.

Example 5 — Wrapper .reverse() vs native .reverse()

Both mutate in place—wrapper .reverse() simply fits into a Lodash chain.

javascript
const data = [10, 20, 30, 40, 50];

const viaWrapper = _(data.slice()).reverse().value();
const viaNative = data.slice().reverse();

console.log(JSON.stringify(viaWrapper) === JSON.stringify(viaNative));
// -> true

Example 6 — Presenting data in reverse order

A common UI pattern: show newest items first by reversing a fetched list copy.

javascript
const timeline = ["event-a", "event-b", "event-c"];

const newestFirst = _([...timeline])
  .reverse()
  .value();

console.log(newestFirst);
// -> ["event-c", "event-b", "event-a"]

console.log(timeline);
// -> ["event-a", "event-b", "event-c"] (unchanged)

🧠 How Wrapper .reverse() Works

1

Wrap the array

Start with _(array) or continue an existing chain after map / filter.

Wrapper
2

Call .reverse()

Lodash reverses the wrapped array elements in place—first becomes last.

Mutate
3

Chain or unwrap

Add more steps or call .value() to return the plain reversed array.

Result
=

Original may change

Unless you wrapped a copy, any reference to the same array sees the reversed order.

📝 Notes

  • There is no _.prototype.reverse() function—the correct name is wrapper .reverse() on a sequence object.
  • Wrapper .reverse() mutates the underlying array, just like native Array.prototype.reverse().
  • Use array.slice() or spread [...array] before wrapping when you must preserve the original order.
  • Mutating wrapper methods like reverse may interact with deferred execution—see .commit() when you need mid-chain flushes.
  • Always end chains with .value() when your app needs plain JavaScript data, not a wrapper.
  • Next in the series: .value() unwraps the chain and returns the final result.

Conclusion

Wrapper .reverse() flips array order inside Lodash chains while mutating the wrapped array in place. It pairs well with map and filter, but remember to copy first when immutability matters.

Next in the wrapper prototype series: .value(), the method that unwraps your chain and returns plain data.

💡 Best Practices

✅ Do

  • Copy the array with slice() or spread when the original must stay unchanged
  • Chain map / filter before reverse for expressive pipelines
  • Call .value() at the end when passing data to non-Lodash code
  • Log both the result and source while learning to confirm mutation behavior
  • Use .commit() when you need mutating steps flushed mid-chain

❌ Don’t

  • Call it _.prototype.reverse()—that name does not exist in Lodash
  • Assume .reverse() returns a new array—it mutates in place
  • Reverse shared arrays without checking if other code still needs the original order
  • Forget that wrapper .reverse() returns a wrapper, not plain data
  • Use wrapper reverse on plain arrays when a simple [...arr].reverse() reads clearer

Key Takeaways

Knowledge Unlocked

Five things to remember about wrapper .reverse()

Use these when reversing arrays inside Lodash chains safely.

5
Core concepts
⚠️ 02

Mutates array

Source changes.

Critical
🔄 03

Chain transforms

map, filter, etc.

Pattern
📦 04

Copy first

slice / spread.

Safety
🛠️ 05

Then .value()

Unwrap result.

Guideline

❓ Frequently Asked Questions

It reverses the order of elements in the wrapped array in place and returns the wrapper so you can keep chaining or call .value() to unwrap.
Yes. Like native Array.prototype.reverse(), wrapper .reverse() mutates the underlying array. The original variable still points to the same array object—now reversed.
Wrap a shallow copy first: _([...array]).reverse() or _(array.slice()).reverse(). The source array stays unchanged.
No. It returns a wrapper. Call .value() at the end of the chain to get a plain JavaScript array.
Both mutate in place. Wrapper .reverse() is for chained pipelines on _(value); _.reverse(array) is the standalone function form.
No. The correct API is wrapper .reverse() on the object returned by _(value) or _.chain(value).
Did you know?

Wrapper .reverse() delegates to the same in-place algorithm as native Array.prototype.reverse()—Lodash just lets you slot it between other chain steps like map and filter without breaking the pipeline style.

Practice Wrapper .reverse() in the Live Editor

Reverse arrays in chains and compare mutable vs copy-safe patterns.

Open Try It editor →

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