Thursday, October 23, 2025
HomeLanguagesJavascriptLodash _.curryRight() Method

Lodash _.curryRight() Method

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.

The _.curryRight() method is used to return a curried version of the given function where the given arguments are processed from right to left.

Syntax:

_.curryRight( fun )

Parameters: This method takes a single parameter as listed above and discussed below.

  • fun: This is the function that should be used in the curried version.

Return Value: This method returns the curried function.

Note: This method will not work in normal JavaScript because it requires the Lodash contrib library to be installed. The lodash-contrib library can be installed using npm install lodash-contrib –save

Example 1: 

Javascript




// Defining lodash contrib variable
var _ = require('lodash-contrib'); 
  
// Function to curry
function div(a, b, c) {
    return a / b / c;
}
  
// Using the _.curryRight() method
var curried = _.curryRight(div);
  
console.log("Curried division is :",
    curried(3)(3)(99));


Output:

Curried division is : 11

Example 2:

Javascript




// Defining lodash contrib variable
var _ = require('lodash-contrib'); 
  
// Function to curry
function div(a, b, c, d) {
    return a - b - c - d;
}
  
// Using the _.curryRight() method
var curried = _.curryRight(div);
  
console.log("Curried Subtraction is :",
    curried(2)(1)(6)(44));


Output: 

Curried Subtraction is : 35

Example 3:

Javascript




// Defining lodash contrib variable
var _ = require('lodash-contrib'); 
  
// Function to curry
function div(a, b, c) {
    return ("a=" + a + " and b=" + b +
            " and c=" + c);
}
  
// Using the _.curryRight() method
var curried = _.curryRight(div);
  
console.log(curried("a")("b")("c"));


Output: 

a=c and b=b and c=a
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS