Member-only story
Functional Programming: Higher Order Functions
A Better Take on JavaScript’s Higher Order Functions.

Functional Programming is awesome! It makes programming fun.
Learning to program “functionally” is going to make you a fantastic programmer and you will feel secure with the quality of your work.

You will be able to write your programs with fewer bugs and in less time because you will be able to re-use your code.
Within this paradigm, we will focus on one of the most important concepts in functional programming, and that is Higher-Order Functions.
So let’s get started!
In JavaScript, and in many functional programming languages, functions are values.
Let’s take a simple function for example:
function double(x) {
return x * 2
}
What is super cool about JavaScript is that we can take this function and make it into an anonymous function to pass it around and re-use it by declaring a variable.
let double = function(x) {
return x * 2
}let pancake = double pancake(40) // 80
We declared a variable double and assigned it to the anonymous function. Then we declared another variable, pancake, and assign it to the same function. Just like strings and numbers, functions too can be assigned to variables.
So, in functional programming, functions are values and they can be assigned to variables and they can also be passed into other functions.
Functions that operate on other functions, either by taking them as arguments or by returning them, are called higher-order functions. — see Eloquent JavaScript
In other words, as pertaining to our example, higher-order functions can be understood as functions being passed into other functions to do awesome things!!!