Lodash _.forOwnRight() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Like _.forOwn, but iterates own enumerable string keys of object in the opposite order. Inherited prototype keys are skipped. Part of Lodash Object since 2.0.0 (stable — not deprecated).

Pass the object and path or keys shown below. Check whether the helper mutates or returns a new object.

Syntax

Call _.forOwnRight. Start with this line.

Lodash
_.forOwnRight(object, [iteratee])
CallWhat it does
_.forOwnRight(object, [iteratee])Primary signature.
_.forOwnRight(object)Work with an object’s keys, values, or paths.

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

Library declarations
Lodash
_.forOwnRight(object, [iteratee])

Parameters

ParameterDescription
objectRequired. The object to iterate over
iterateeOptional. Invoked per key; default _.identity

Return Value

Return ValueDescription
*The original object

Lodash Examples

Example 1 — Official: Reverse Own Keys

Own keys are visited opposite to _.forOwn; prototype c is skipped.

Lodash
function Foo() {
  this.a = 1;
  this.b = 2;
}

Foo.prototype.c = 3;

_.forOwnRight(new Foo, function(value, key) {
  console.log(key);
});
// → Logs 'b' then 'a'
//    (assuming _.forOwn logs 'a' then 'b')
Try It Yourself

How It Works

  1. Instance. Own keys a and b; prototype key c.
  2. forOwn order. Typically a → b.
  3. forOwnRight. Walks that sequence backward.
  4. Skip. Inherited c is never visited.

Example 2 — Side-by-Side With _.forOwn

Same own keys; only the direction changes.

Lodash
var obj = { a: 1, b: 2, c: 3 };
var left = [];
var right = [];

_.forOwn(obj, function (v, k) { left.push(k); });
_.forOwnRight(obj, function (v, k) { right.push(k); });

// left  → ["a", "b", "c"]  (typical)
// right → ["c", "b", "a"]
Try It Yourself

How It Works

  1. Collect keys. Push each key into an array.
  2. Forward. forOwn fills left-to-right order.
  3. Reverse. forOwnRight fills the opposite sequence.
  4. Same set. Both skip inherited keys.

Example 3 — Iterate Values Too

The iteratee receives value and key on every step.

Lodash
var obj = { a: 1, b: 2, c: 3 };
var pairs = [];

_.forOwnRight(obj, function (value, key) {
  pairs.push(key + "=" + value);
});

// pairs → ["c=3", "b=2", "a=1"]
Try It Yourself

How It Works

  1. Plain object. Three own enumerable keys.
  2. Iteratee. Builds key=value strings.
  3. Order. Starts at the last key (c).
  4. Use. Side effects, logging, or collecting results yourself.

Example 4 — Early Exit With false

Return false to stop before every key is visited.

Lodash
var obj = { a: 1, b: 2, c: 3 };
var seen = [];

_.forOwnRight(obj, function (value, key) {
  seen.push(key);
  if (key === 'b') {
    return false;
  }
});

// seen → ["c", "b"]  (stops before "a")
Try It Yourself

How It Works

  1. Start. First visit is c.
  2. Next. Visit b and return false.
  3. Stop. a is never visited.
  4. Note. Only an explicit false breaks — other falsy returns do not.

Example 5 — vs _.forInRight

Inherited keys appear in forInRight, not in forOwnRight.

Lodash
function Foo() {
  this.a = 1;
  this.b = 2;
}
Foo.prototype.c = 3;

var ownRight = [];
var inRight = [];

_.forOwnRight(new Foo(), function (v, k) { ownRight.push(k); });
_.forInRight(new Foo(), function (v, k) { inRight.push(k); });

// ownRight → ["b", "a"]
// inRight  → ["c", "b", "a"]
Try It Yourself

How It Works

  1. forOwnRight. Own keys only → b, a.
  2. forInRight. Includes prototype key c.
  3. Both reverse. Direction is reversed relative to their forward counterparts.
  4. Choose. Use forOwnRight when inherited keys must be ignored.

Browser & Runtime Support

_.forOwnRight is a Lodash Object helper (available since 2.0.0, stable in 4.x). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 2.0.0+

_.forOwnRight()

Available in [email protected] full builds and the lodash/forOwnRight 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
_.forOwnRight Lodash 2.0.0+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import forOwnRight from "lodash/forOwnRight" for smaller builds. Use _.forInRight when inherited keys must be included.

Frequently Asked Questions

_.forOwnRight(object, iteratee) iterates over an object's own enumerable string-keyed properties in the opposite order of _.forOwn. It returns the original object.
The iteratee is invoked with (value, key, object).
Yes. Explicitly return false from the iteratee to exit iteration early.
Same key coverage (own enumerable string keys only). Opposite walk order.
_.forOwnRight visits own keys only. _.forInRight also visits inherited enumerable keys, also in reverse.
Use import forOwnRight from "lodash/forOwnRight" or require("lodash/forOwnRight"). Full build: import _ from "lodash" then _.forOwnRight.

Next: _.functions()

Return the names of an object’s own enumerable function properties.

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