Last Updated : 03 Sep, 2024
Lodash _.overArgs() method is used to create a function that invokes func with its arguments transformed using the given transforms function.
Syntax:_.overArgs(func, transforms );Parameters:
Example 1: In this example, we are using the lodash _.overArgs() method and passing two parameters to it, which is calling two other functions respectively and giving the output as an array in the console.
JavaScript
// Requiring the lodash library
const _ = require("lodash");
// Function to calculate the
// Cube of a number
function Cube(number) {
return number * number * number;
}
// Function to calculate the
// triple value of a number
function Triple(number) {
return number * 3;
}
// Using the _.overArgs() method
let func = _.overArgs(function (a, b) {
return [a, b];
}, [Cube, Triple]);
// print the output
console.log(func(3, 5));
Output:
[27, 15]
Example 2: In this example, we are using the lodash _.overArgs() method and passing two parameters to it, which is calling two other functions respectively and giving the output as an array in the console.
JavaScript
// Requiring the lodash library
const _ = require("lodash");
// Function to calculate the
// double value of a number
function doubled(number) {
return number * 2;
}
// Function to calculate the
// square value of a number
function square(number) {
return number * number;
}
// Using the _.overArgs() method
let func = _.overArgs(function (a, b) {
return [a, b];
}, [square, doubled]);
// print the output
console.log(func(5, 8));
Output:
[25, 16]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4