Higher Order Functions
Earlier we saw examples of .map()
and .filter()
. Both of them take a function as an argument. They’re both higher order functions. A higher order function is a function that takes a function as an argument, or returns a function. Higher order function is in contrast to first order functions, which don’t take a function as an argument or return a function as output.
Let’s look at an example of a first-order function which filters all the 4-letter words from a list of words:
Get Composing Software now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.