Lodash _.ary() Method

The Lodash _.ary() method is used to create a function that invokes the given function, up to n arguments, ignoring any additional arguments.
Syntax:
_.ary( func, n )
Parameters: This method accepts two parameters as mentioned above and described below:
- func: This parameter holds the function which will cap arguments for.
- n: This parameter holds the number n which element will be capped.
Return Value: This method returns the new capped function.
Note: If you use 0 it will cap each element.
The below example illustrates the Lodash _.ary() method:
Example 1:
Javascript
| // Requiring the lodash library   const _ = require("lodash");  Â// Applying _.ary() method vargfg =_.map(['6', '8', '10'],         _.ary(parseInt, 2));  Âconsole.log(gfg); | 
Output:
[ 6, NaN, 2 ]
Example 2:
Javascript
| // Requiring the lodash library   const _ = require("lodash");  Â// Applying _.ary() method vargfg =_.map(['6', '8', '10'],          _.ary(parseInt, 1));  Âconsole.log(gfg); | 
Output:
[ 6, 8, 10 ]
Reference: https://docs-lodash.com/v4/ary/
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek 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!
 
				 
					


