how to use the over function from lodash in javascript

_.over is a function in lodash that creates a function that applies other functions to a list of arguments, returning an array of the results.

The syntax of _.over is as follows:

index.tsx
_.over([iteratees])
20 chars
2 lines

Here, iteratees is an array of functions that should be applied.

Example usage:

index.tsx
const multiply = (a, b) => a * b;
const square = x => x * x;
const double = x => x * 2;

const func = _.over([multiply, square, double]);
console.log(func(3, 4)); // [12, 9, 6]
177 chars
7 lines

In the above example, func is a function created using _.over and applies the functions multiply, square, and double to the arguments (3, 4). As a result, it returns an array [12, 9, 6], which are the respective results of each function applied to the arguments.

Note that when using _.over, the functions are applied in the order they are specified in the iteratees array.

gistlibby LogSnag