Lodash _.curryRight() Method
Last Updated :
27 Oct, 2023
Lodash _.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:
- fun: This is the function that should be used in the current version.
Return Value:
This method returns the curried function.
Example 1: In this example, we are using the lodash _.curryRight() method and it invokes the function by right to left parameters.
Javascript
let _ = require( 'lodash' );
function div(a, b, c) {
return a / b / c;
}
let curried = _.curryRight(div);
console.log( "Curried division is :" ,
curried(3)(3)(99));
|
Output:
Curried division is : 11
Example 2: In this example, we are using the lodash _.curryRight() method and it invokes the function by right to left parameters.
Javascript
let _ = require( 'lodash' );
function div(a, b, c, d) {
return a - b - c - d;
}
let curried = _.curryRight(div);
console.log( "Curried Subtraction is :" ,
curried(2)(1)(6)(44));
|
Output:
Curried Subtraction is : 35
Example 3: In this example, we are using the lodash _.curryRight() method and it invokes the function by right to left parameters.
Javascript
let _ = require( 'lodash' );
function div(a, b, c) {
return ( "a=" + a + " and b=" + b +
" and c=" + c);
}
let curried = _.curryRight(div);
console.log(curried( "a" )( "b" )( "c" ));
|
Output:
a=c and b=b and c=a
Share your thoughts in the comments
Please Login to comment...