Lodash _.rangeRight() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Util

Definition

Creates an array of numbers progressing from start up to, but not including, end — same as _.range, except values are populated in descending order. Part of Lodash Util since 4.0.0 (stable — not deprecated).

Pass the arguments shown below. Prefer modular imports when you only need this helper.

Syntax

Call _.rangeRight. Start with this line.

Lodash
_.rangeRight([start=0], end, [step=1])
CallWhat it does
_.rangeRight([start=0], end, [step=1])Primary signature.
_.rangeRight(...)Call the util helper.

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

Library declarations
Lodash
_.rangeRight([start=0], end, [step=1])

Parameters

ParameterDescription
startOptional. Start of the range (default 0)
endRequired. Exclusive end (*alone as one-arg form)
stepOptional. Increment (default 1; -1 if negative end without step)

Return Value

Return ValueDescription
*Number array filled from the right

Lodash Examples

Example 1 — Official: One Argument

End only — start defaults to 0, array filled from the right.

Lodash
_.rangeRight(4);
// → [3, 2, 1, 0]

_.rangeRight(-4);
// → [-3, -2, -1, 0]
Try It Yourself

How It Works

  1. End 4. Same set as _.range(4) → 0..3.
  2. Reverse fill. Array becomes [3, 2, 1, 0].
  3. End −4. Negative end uses step −1 by default.
  4. Result. [-3, -2, -1, 0] — reverse of _.range(-4).

Example 2 — Official: Start and End

Exclusive end — stops before 5.

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

How It Works

  1. Bounds. Start 1, end 5 (not included).
  2. Set. Values 1, 2, 3, 4.
  3. Order. Stored high → low → [4, 3, 2, 1].
  4. Use. Handy for reverse index walks.

Example 3 — Official: Custom Step

Step of 5 from 0 toward 20.

Lodash
_.rangeRight(0, 20, 5);
// → [15, 10, 5, 0]

_.rangeRight(0, -4, -1);
// → [-3, -2, -1, 0]

_.rangeRight(1, 4, 0);
// → [1, 1, 1]
Try It Yourself

How It Works

  1. Step 5. Forward values 0, 5, 10, 15 → reversed array.
  2. Negative step. Same set as _.range(0, -4, -1), reverse order.
  3. Step 0. Lodash repeats start for the length of the range.
  4. Rule. Step controls spacing; rangeRight controls fill order.

Example 4 — rangeRight vs range

Same arguments, opposite array order.

Lodash
_.range(1, 5);
// → [1, 2, 3, 4]

_.rangeRight(1, 5);
// → [4, 3, 2, 1]

// countdown with step (not the same as rangeRight alone):
_.range(4, 0, -1);
// → [4, 3, 2, 1]
Try It Yourself

How It Works

  1. range. Low → high fill.
  2. rangeRight. Same set, high → low fill.
  3. Negative step. Changes direction of the progression itself.
  4. Pick. Want reverse storage of an ascending set → rangeRight; want step direction → negative step.

Browser & Runtime Support

_.rangeRight is a Lodash Util helper since 4.0.0. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 4.0.0+

_.rangeRight()

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

100% With Lodash 4.0+
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
_.rangeRight Lodash 4.0.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import rangeRight from "lodash/rangeRight" for smaller bundles.

Frequently Asked Questions

_.rangeRight([start=0], end, [step=1]) builds the same numbers as _.range with the same arguments, but fills the array in reverse order — last value first.
Same parameters and exclusive end. _.range(1, 5) → [1, 2, 3, 4]. _.rangeRight(1, 5) → [4, 3, 2, 1]. Only the array order changes.
No. End is exclusive — same as _.range. _.rangeRight(1, 5) stops before 5.
The single value is end; start defaults to 0. _.rangeRight(4) → [3, 2, 1, 0], the reverse of _.range(4).
Use a negative step with _.range: _.range(10, 0, -1). rangeRight reverses array order; it does not flip the step direction by itself.
No. It is a stable Lodash Util method since 4.0.0.

Next: _.runInContext()

Create a pristine Lodash copy for safe mixins and plugins.

_.runInContext() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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