Lodash _.partial() Method

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.partial() method is used to create a function which invokes the given func function with prepended partials to the arguments it receives.
Syntax:
_.partial( func, partials )
Parameters: This method accepts two parameters as mentioned above and described below:
- func: This parameter holds the function to partially apply the arguments to.
- partials: This parameter holds the arguments to be applied. It is an optional parameter.
Return Value: This method returns the new partially applied function.
Example 1:
Javascript
| // Requiring the lodash library   const _ = require("lodash");    Â// Given Function functioninfo(information, name) {   console.log(information + ' '+ name); }  Â// Using the _.partial() method   varcall_gfg =   _.partial(info, 'zambiatek'); call_gfg('is a computer science portal for zambiatek'); | 
Output:
'zambiatek is a computer science portal for zambiatek'
Example 2: Â
Javascript
| // Requiring the lodash library   const _ = require("lodash");    Â// Given Function functioninfo(information, name) {   console.log(information + ' '+ name); }  Â// Using the _.partial() method   varsay_gfg = _.partial(info, _, 'zambiatek'); say_gfg('Hello'); | 
Output:
'Hello zambiatek'
 
				 
					


