Tuesday, July 28, 2026
HomeLanguagesJavascriptUnderscore.js _.rCurry() Method

Underscore.js _.rCurry() Method

The Underscore.js _.rCurry() method returns a curried version of the given function where arguments are processed from right to left.

Syntax:

_.rCurry( fun )

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

  • fun: This is the given function passed as parameter.

Return Value: This method returns a curried function.

Note: To execute the below examples, you have to install the underscore-contrib library by using this command prompt and execute the following command.

npm install underscore-contrib

Example 1: 




// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
// Function
function div(a, b, c) {
    return a/b/c;
}
  
var curried = _.rCurry(div);
  
console.log("Curried division is :", 
    curried(2)(4)(16));


Output:

Curried division is : 2

Example 2:




// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
// Function
function div(a, b, c, d) {
    return a-b-c-d;
}
  
var curried = _.rCurry(div);
  
console.log("Curried Subtraction is :", 
    curried(2)(4)(16)(44));


Output: 

Curried Subtraction is : 22

Example 3: Arguments are reversed as shown below:




// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
// Function
function div(a, b, c) {
    return ("a="+a+" and b="+b+" and c="+c);
}
  
var curried = _.rCurry(div);
  
console.log(curried("a")("b")("c"));


Output: 

a=c and b=b and c=a
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
32520 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6903 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12115 POSTS0 COMMENTS
Shaida Kate Naidoo
7023 POSTS0 COMMENTS
Ted Musemwa
7265 POSTS0 COMMENTS
Thapelo Manthata
6980 POSTS0 COMMENTS
Umr Jansen
6973 POSTS0 COMMENTS