Lodash _.partialRight() Method
Lodash _.partialRight() method is used to create a function that invokes the given func function with the appended partials to the arguments it receives. It is almost the same as the _.partial() function.
Syntax:
_.partialRight(func, partials);
Parameters:
- func: This parameter holds the function to partially apply arguments.
- partials: This parameter holds the arguments to be partially applied. It is an optional parameter.
Return Value:
This method returns the new partially applied function.
Example 1: In this example, we are passing a string partially to the function by the use of the lodash _.partialRight() method.
Javascript
// Requiring the lodash library const _ = require( "lodash" ); // Given Function function info(information, name) { console.log(information + ' ' + name); } // Using the _.partialRight() method let call_gfg = _.partialRight(info, 'is a computer science portal' ); call_gfg( 'w3wiki' ); |
Output:
'w3wiki is a computer science portal'
Example 2: In this example, we are passing a string partially to the function by the use of the lodash _.partialRight() method.
Javascript
// Requiring the lodash library const _ = require( "lodash" ); // Given Function function info(information, name) { console.log(information + ' ' + name); } // Using the _.partialRight() method // with placeholders let say_gfg = _.partialRight(info, 'Hello' , _); say_gfg( 'Beginner' ); |
Output:
'Hello Beginner'
Contact Us