Higher Order Function
Higher-order functions are functions that take other functions as arguments or return functions as their results.
Call Back Functions
The functions which is pass as an argument is known as call back function.
Example:
Here, filterOdd function is a Higher order function as it is accepting isOdd function as an argument and also returning finalArray.
isOdd is a call back function as it is passed as an argument in filterOdd function
Use cases of Higher Order Function
Without Higher-order function
With Higher-order function(Map)
with use of higher order function we can write short and accurate code where chances of getting error is very less
Similarly, some methods of string and array i.e reduce, filter, some, map use call back function to compute output
Top comments (0)