Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptLodash _.partialRight() Method

Lodash _.partialRight() 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 _.partialRight() method is used to create a function which invokes the given func function with the appended partials to the arguments it receives. It is almost the same as _.partial() function.

Syntax:

_.partialRight( func, partials )

Parameters: This method accepts two parameters as mentioned above and described below:

  • func: This parameter holds the function to partially apply arguments to.
  • 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:

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
  
// Given Function
function info(information, name) {
  console.log(information + ' ' + name);
}
  
// Using the _.partialRight() method  
var call_gfg =
  _.partialRight(info,
    'is a computer science portal');
call_gfg('neveropen');


Output:

'neveropen is a computer science portal'

Example 2:  

Javascript




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


Output:

'Hello neveropen'

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments