Lodash _.over() method is used to create a function that invokes iteratee with the arguments it receives and returns its results.
Syntax:
_.over(iteratees);
Parameters:
- iteratee: The iteratee to invoke.
Returns:
This method returns a new function.
Example 1: In this example, we are checking whether the given value is a finite number or not and printing the boolean result according to it in the console.
Javascript
const _ = require( "lodash" );
let func = _.over([Boolean, isFinite]);
let gfg1 = func( '10' );
let gfg2 = func( '-5' );
let gfg3 = func( 'null' );
let gfg4 = func( 'NaN' );
console.log(gfg1);
console.log(gfg2);
console.log(gfg3);
console.log(gfg4);
|
Output:
[true, true]
[true, true]
[true, false]
[true, false]
Example 2: In this example, we are printing the min and max number from the gievn values in the console.
Javascript
const _ = require( "lodash" );
let func = _.over([Math.min, Math.max]);
console.log(func(5, 10, 20));
|
Output:
[-5, 20]
Last Updated :
03 Nov, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...