Friday, October 10, 2025
HomeLanguagesJavascriptLodash _.partial() Method

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
function info(information, name) {
  console.log(information + ' ' + name);
}
  
// Using the _.partial() method  
var call_gfg =
  _.partial(info, 'neveropen');
call_gfg('is a computer science portal for neveropen');


Output:

'neveropen is a computer science portal for neveropen'

Example 2:  

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
  
// Given Function
function info(information, name) {
  console.log(information + ' ' + name);
}
  
// Using the _.partial() method  
var say_gfg = _.partial(info, _, 'neveropen');
say_gfg('Hello');


Output:

'Hello neveropen'
Previous article
Next article
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32350 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6718 POSTS0 COMMENTS
Nicole Veronica
11880 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6838 POSTS0 COMMENTS
Ted Musemwa
7101 POSTS0 COMMENTS
Thapelo Manthata
6794 POSTS0 COMMENTS
Umr Jansen
6794 POSTS0 COMMENTS