Lodash - partialRight method
Syntax
_.partialRight(func, [partials])
This method is like _.partial except that partially applied arguments are appended to the arguments it receives.
Arguments
func (Function) − The function to partially apply arguments to.
[partials] (...*) − The arguments to be partially applied.
Output
(Function) − Returns the new partially applied function.
Example
var _ = require('lodash');
var divide = function(a, b) { return b / a};
var divideBy5 = _.partialRight(divide, 5);
var result = divideBy5(10);
console.log(result);
var divisionOf10 = _.partialRight(divide, _, 10)
result = divisionOf10(5)
console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
0.5 2
lodash_function.htm
Advertisements