Saturday, February 7, 2026
HomeLanguagesJavascriptLodash _.forEachRight() Method

Lodash _.forEachRight() Method

The Lodash _.forEachRight() method iterates over elements of collection from right to left. It is almost the same as the _.forEach() method.

Syntax:

_.forEachRight( collection, iteratee )

Parameters: This method accepts two parameters as mentioned above and described below:

  • collection: This parameter holds the collection to iterate over.
  • iteratee: It is the function that is invoked per iteration.

Return Value: This method returns the collection.

Example 1:

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
  
// Use of _.forEachRight() method 
_.forEachRight(['c', 'cpp', 'java',
      'python'], function(value) {
    console.log(value);
});


Output:

python
java
cpp
c

Example 2:  

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
  
// Use of _.forEachRight() method 
_.forEachRight({ 'x': 1, 'y': 2 }, 
    function(value, key) {
        console.log(key);
});


Output:

y
x

Note: This will not work in normal JavaScript as it requires the lodash library to be installed. 
Reference: https://lodash.com/docs/4.17.15#forEachRight

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32493 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6864 POSTS0 COMMENTS
Nicole Veronica
11990 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12083 POSTS0 COMMENTS
Shaida Kate Naidoo
7000 POSTS0 COMMENTS
Ted Musemwa
7240 POSTS0 COMMENTS
Thapelo Manthata
6951 POSTS0 COMMENTS
Umr Jansen
6936 POSTS0 COMMENTS