Better understanding higher order functions - helpful resources

Higher order functions was difficult for me too this video helped.

I breezed through most of the JS tutorial, but that section scared me. It felt as if the tutor was speaking too fast. I sat down this morning to have a go at it and I solved it on the first try.
If they can split that exercise into different steps, it would be much easier to follow.
It’s also annoying that I had to use other resources aka. FreeCodeCamp to understand what was being taught.

Personally, I like symbols, and despise long descriptive variable names at the processing level. Had this lesson been less verbose it might have had a greater chance of dissemination. As it is, it even confuses me. But then…

i think a lot of the ocnfusion and referincing online examples is the assumptoin of usage of objects which they haven’t covered yet - however, this was one of the best articles I saw -

I’ve watched this video several times, and for me, I didn’t find it super helpful. I’m sure we all agree Brad Traversy’s awesome, but in this particular video he demonstrated a handful JavaScript methods on arrays. I wished he’d explained better why they take the parameters they do (but I know that’s all a matter of ''Look it up in MDN"). I also felt like he quickly rushed through the concise body arrow function expressions - nice to see, but I would have much rather had more in-depth explanation of the concepts. It was a good review of Codecademy material, but for me it didn’t help me understand HOFs better.

I’ve yet to find THE video that enables my brain to wrap my head around this concept fully, but this one definitely helped me. FYI, I played this one at 1.75x speed which somehow helped. Just a suggestion.

There are basically two types of higher order functions: One that takes a function and then uses that function internally to arrive at a return value; for instance,


where callback is a function that does something with each object in the array as forEach iterates that array.


where callback is a predicate function (returns a boolean) where only the array elements that satisfy the predicate will be added to the return array.

where the callback is a function to compute a new value from each of those values in Array and return an array of the new values.


where callback is a function that computes a value, such as a + b while progressively reducing the Array elements to a single return value.

The other type is one that returns a function composed of the arguments passed in and that can be invoked at a later time.

times = a = > x => a * x

f = times(5)

console.log(f(25))    //  125

Notice that a is now a constant in f and x is the parameter?


Think of maths…

f(x) = ax

We’ve defined f(x) as, f(x) = 5x.

This is very common functionality when we get into the stew of things. You’ll find a million uses for both forms of HOF as you progress. Definitely segue into deeper study if this is a hanging point. It will be time well spent, and I mean practice, not videos.

1 Like

To be honest the higher order functions directions and teaching in this section is horrid. @Codeacademy please review this module it can use a lot of work. I understand functions and will say your jumping from 0 to 60 on this one!!!


ROFL, this is exactly what happening to me right now. I don’t know is there is a problem with the instructions or just a problem of my understanding :frowning:


This is my take on the understanding of higher order functions and passing functions as parameters

1 Like

Right. The description given has example codes which are complicated.
If the example codes have functions defined using ‘function’ keyword, it would be very easy to understand. The function definitions using fat arrow (=>) are a bit difficult to understand for new programmers.

1 Like

Can some one kindly let me know what is the argument/value for parameter (y) in the syntax below…? If the answer is 4, tell me How 4 becomes the argument for (y)?
Many thanks

function one (x) {
return function (y) {
return x + y

var tom = one(2);
tom(4) // prints 6


Function one is a factory that returns a function with a constant in the x variable.

tom  =>  function (y) {
           return 2 + y;

I’ll definetly check out the articles. The instructions are still a bit cloudy but I guess it’s a part of the learning process. Thank you so much for the help!

This subject became my nightmare and for the last 2 days I run upside down all the resources! By far the best explanation came from this youtube channel:

This is really helpful! Thanks for sharing :grin:

Thx for the resources//

It’s so complicated to understand this chapter. And, I feel the description of the exercise is tough to know what it means for.

Higher-order functions, although are very powerful, using too many of them might decrease your code readability. Higher order functions follow the DRY (Don’t Repeat Yourself) rule, and, I cannot stress upon this enough, are very powerful. They are perfect, except the fact that they are hard to visualize and understand. If you can use them without any hassle, I respect you.