What is Higher Order Function ?

What is Higher Order Function ?

Table of contents

No heading

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

what

No Worries

noworry

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.

Did you find this article valuable?

Support Anup Gurung by becoming a sponsor. Any amount is appreciated!