Table of contents
No headings in the article.
So what is higher order function ?
we have been using and creating function in javascript for long now but have we ever came across any thing sort of Higher Order Function
No Worries
Let us start by creating a a first class function.
functions that can be assigned to any regular variables, passed as an arguments to functions, returned as a result of function can be termed as First Class Function
“A programming language is said to have First-class functions when functions in that language are treated like any other variable.” — MDN
so we just created a first class function now what ? Yes i know you might be thinking this is what we have been doing on daily basis now what so new ?
ok now let just modify the above code and implement the higher order function
The above code might look familiar to some or us who have been working with such function which can take function as an argument but might not know the term. Well there it is you clean looking Higher Order function.
Higher Orders Functions are functions that perform operations on other functions.
In this definition, operations can mean taking one or more functions as an argument OR returning a function as the result.
Some most commonly used function are filter(), map() etc from array.
Conclusion
Higher Order Functions provide a higher level of abstraction for functions.