Lodash _.over() Method

The 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: This method accepts one parameter as mentioned above and described below:

  • iteratee: The iteratee to invoke.

Returns: This method returns a new function.

Example 1:



Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

// Requiring the lodash library  
const _ = require("lodash");              
  
// Use of _.over() method 
var func = _.over([Boolean, isFinite]);
  
// Saving the result
let gfg1 = func('10');
let gfg2 = func('-5');
let gfg3 = func('null');
let gfg4 = func('NaN');
       
// Printing the output  
console.log(gfg1); 
console.log(gfg2); 
console.log(gfg3); 
console.log(gfg4);

chevron_right


Output:

[true, true]
[true, true]
[true, false]
[true, false]

Example 2:

Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

// Requiring the lodash library  
const _ = require("lodash");              
  
// Use of _.over() method 
var func = _.over([Math.min,  Math.max]);
  
// Saving the result
let gfg = func(5, 10, -5, 20);
  
       
// Printing the output  
console.log(gfg);

chevron_right


Output:

[-5, 20]

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.