Lodash – curry method

  • Post author:
  • Post category:Lodash
  • Post comments:1 Comment
Lodash - curry method

Syntax Of Lodash curry method

_.curry(func, [arity=func.length])

Lodash curry method creates a function that accepts arguments of func and either invokes func returning its result, if at least arity number of arguments have been provided, or returns a function that accepts the remaining func arguments and so on. The arity of func may be specified if func. length is not sufficient.


  • func (Function) โˆ’ The function to curry.
  • [arity=func.length] (number) โˆ’ The arity of func.


  • (Function) โˆ’ Returns the new curried function.


var _ = require('lodash');
var getArray = function(a, b, c) {
   return [a, b, c];
var curried = _.curry(getArray);
console.log(curried(1, 2)(3));
console.log(curried(1, 2, 3));

Save the above program in tester.js. Run the following command to execute this program.


\>node tester.js


[ 1, 2, 3 ]
[ 1, 2, 3 ]
[ 1, 2, 3 ]

Next Topic – Click Here

This Post Has One Comment

Leave a Reply