---
title: "Discussion on \"ES6 - Higher-Order Functions\" | Hashnode"
description: "Discussion on \"ES6 - Higher-Order Functions\". Introduction\nIn this article, we will first understand what a higher-order function is and then look at a few code examples of the popular higher-order functions such as forEach, map, filter, reduce, etc.\nWhat are Higher Order Functions?\nIt is import..."
url: "https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [ES6 - Higher-Order Functions](https://blog.skay.dev/es6-higher-order-functions?utm_source=hashnode&utm_medium=feed)

Introduction In this article, we will first understand what a higher-order function is and then look at a few code examples of the popular higher-order functions such as forEach, map, filter, reduce, etc. What are Higher Order Functions? It is import...

Oct 14, 2020 · 14 min read · blog.skay.dev  
Updated Oct 22, 2020  
Read the article

-   [#100daysofcode](https://hashnode.com/tag/100daysofcode)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#webdev](https://hashnode.com/tag/webdev)

## Written by

[Skay](https://hashnode.com/@skay)

@skay · Kitchener, Canada

  
[View profile](https://hashnode.com/@skay)

I love to build cool things on the web...

I am a Technical Product Manager and have over two decades of experience building products for enterprises and start-ups. I love to ideate, create things on the web and my expertise lies in how to translate user value when we build engineering solutions.

## Responses 6

Markdown supported · ⌘↵ to post

[Ruslan Zubenko](https://hashnode.com/@Zubiwub)

[Oct 16, 2020](https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304/comment/5f896c32d7dc0b17a97a1e34)

Thank you for a very clear and concise article!

[Skay](https://hashnode.com/@skay)

[Oct 16, 2020](https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304/comment/5f896c32d7dc0b17a97a1e34#reply-5f896c646eb39417ce5e4e38)

Thanks for reading ❤️

[Bob Jones](https://hashnode.com/@crazy4groovy)

[Oct 15, 2020](https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304/comment/5f8872136eb39417ce5e43c6)

Hi [Skay](https://hashnode.com/@skay), thanks for the article.

There is an incorrect comment in your code:

```
//Higher order function - takes 'func' as an argument & returns a 'func' for execution
const higherOrderFunction = function(func, a, b) {
    return func(a, b);
}
```

This function is not actually returning a function, but rather the result of the callback function, which is data.

A more concise example might be:

```
const sum = function(a, b) {
    return a + b;
}
//Higher order function - takes 'func' as an argument & returns a 'func' for execution
const higherOrderFunction = (func) => (a, b) => {
    return func(a, b);
}
const sumFor = higherOrderFunction(sum);
console.log(sumFor(2,3));
```

Here, `higherOrderFunction` takes `func` and returns a function, which then takes `a,b` and return data.

Cheers!

[Skay](https://hashnode.com/@skay)

[Oct 15, 2020](https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304/comment/5f8872136eb39417ce5e43c6#reply-5f887bbf6eb39417ce5e4455)

[Bob Jones](https://hashnode.com/@crazy4groovy) - Thank you for catching this! While I had intended to convey what you had indicated it, I did not want to use arrow functions and it got a little messy.

I have updated the main section of code, with your code snippet and included additional comments on what the higher-order function returns.

Once again, thank you for catching this. Really appreciate it!!

[Nimrod Kramer](https://hashnode.com/@nimrodkramer)

[Oct 15, 2020](https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304/comment/5f88010a4aeeb354354ed259)

Congrats on being Featured on daily.dev! The badge looks great on your post :) [Skay](https://hashnode.com/@skay)

[Skay](https://hashnode.com/@skay)

[Oct 15, 2020](https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304/comment/5f88010a4aeeb354354ed259#reply-5f8801e432eeca54569a37f3)

Thanks for the love [Nimrod Kramer](https://hashnode.com/@nimrodkramer) :-)

[Ahmed Altaai](https://hashnode.com/@ahmedaltaai)

[Oct 14, 2020](https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304/comment/5f87131d42164e4fe94fe90f)

Thorough explanation and very refreshing which will help me in the interview process!

Well done!

[Skay](https://hashnode.com/@skay)

[Oct 14, 2020](https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304/comment/5f87131d42164e4fe94fe90f#reply-5f871999c5c9ff500d6cb3cf)

Comments like these really make it worthwhile the effort... thank you for your kind words... Do share for maximum reach :-)

[Favourite Jome](https://hashnode.com/@Favourite)

[Oct 14, 2020](https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304/comment/5f86a97a4f98e6438943641f)

Hi, the `Array.find & Array.findIndex` example, I didn't understand it clearly, so I decided to run it and I got a different output.

[Skay](https://hashnode.com/@skay)

[Oct 14, 2020](https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304/comment/5f86a97a4f98e6438943641f#reply-5f86b5bc4f98e643894364b6)

[Jome Favourite](https://hashnode.com/@Favourite) - Please accept my apologies. I have corrected the code snippet. Kindly verify the same and let me know if you still do not understand it.

[Favourite Jome](https://hashnode.com/@Favourite)

[Oct 14, 2020](https://hashnode.com/posts/es6-higher-order-functions/5f86951976870f43aa09d304/comment/5f86a97a4f98e6438943641f#reply-5f876a3042164e4fe94feeed)

It's clear now, no need to apologise I'm still a newbie 😊. But accepted. It the same now and I understand too [Skay](https://hashnode.com/@skay)
