Saturday, June 13, 2026
HomeLanguagesJavascriptUnderscore.js _.curry3() Method

Underscore.js _.curry3() Method

The Underscore.js _.curry3() method returns a curried version of the given function but will curry exactly three arguments, no more or less.

Syntax:

_.curry3( 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: It returns a curried version of the 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 fun(a, b, c) {
    return a*b*c;
}
  
// Making curried function
var gfgFunc = _.curry3(fun);
  
// Only operates for exactly two arguments
console.log("Multiplication is :", 
    gfgFunc(20)(23)(2));


Output:

Multiplication is : 920

Example 2:




// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
// Function
function fun(a, b, c) {
    return a-b-c;
}
  
// Making curried function
var gfgFunc = _.curry3(fun);
  
// Only operates for exactly two arguments
console.log("Subtraction is :", 
    gfgFunc(25)(23)(1));


Output: 

Subtraction is : 1

Example 3:




// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
// Function
function fun(x, y, z) {
    return arguments;
}
  
// Making curried function
var gfgFunc = _.curry3(fun);
  
// Only operates for exactly three arguments
console.log("Curried Arguments are :", 
    gfgFunc("a")("b")("c"));


Output: 

Curried Arguments are : [Arguments] { '0': 'a', '1': 'b', '2': 'c' }

Example 4:




// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
// Function
function fun(x, y, z) {
    return arguments;
}
  
// Making curried function
var gfgFunc = _.curry3(fun);
  
// Only operates for exactly three arguments
// For two args, it returns function
console.log(gfgFunc("a")("b"));


Output: 

[Function: mustBeUnary]
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
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS