Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Lodash _.forEachRight() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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

My Personal Notes arrow_drop_up
Last Updated : 14 Sep, 2020
Like Article
Save Article
Similar Reads
Related Tutorials