Saturday, February 21, 2026
HomeLanguagesJavascriptLodash _.mapArgs() Method

Lodash _.mapArgs() Method

The Lodash _.mapArgs() method takes a target function and returns a new function that accepts a mapping function, which in turn returns a function that will map its arguments before calling the original target function.

Syntax:

_.mapArgs( target_function, mapping_function );

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

  • target_function: This parameter is original function called.
  • mapping_function: It is a mapping function to be accepted by the function.

Return Value: This method returns a function.

Note: To execute the below examples, you have to install the lodash-contrib library by using this command prompt and execute the following command.

npm install lodash-contrib

Below examples illustrate the Lodash _.mapArgs() method in JavaScript:

Example 1: we made a function that cubes the given value then adds that value to itself.

Javascript




// Defining lodash contrib variable
var _ = require('lodash-contrib'); 
  
function add (x) 
{ 
    return x + x; }
  
function cube (x) 
{
    return  x * x * x; 
}
  
var cubethenadd = _.mapArgs(add)(cube);
  
console.log(cubethenadd(5))


Output:

250

Example 2: 

Javascript




// Defining lodash contrib variable
var _ = require('lodash-contrib'); 
  
function add (x) 
{ 
    return x + x; }
  
function sub (x) 
{
    return  x - x; 
}
  
var subthenadd = _.mapArgs(add)(sub);
  
console.log(subthenadd(7))


Output:

0
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

Dominic
32506 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6882 POSTS0 COMMENTS
Nicole Veronica
12005 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12099 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7255 POSTS0 COMMENTS
Thapelo Manthata
6967 POSTS0 COMMENTS
Umr Jansen
6956 POSTS0 COMMENTS