Member-only story
Code Can Benefit Life Too
7 Ways Higher Order Functions Can Help Improve Your Life
Adopt Higher Order Functions While You Still Can

One of the fundamental building blocks of JavaScript are functions. That’s enough to intrigue anyone about the semantics of functions when learning JavaScript.
But functions are much more intriguing than that.
“Like what”, you ask?
They can become higher order functions — functions that take other functions as arguments, or functions that return functions as their output.
There’s a whole lot of functions going on in that line — and JavaScript is no different. In JavaScript, functions are everywhere. And you should feel blessed that they are!
Here are 7 Ways Higher Order Functions Can Improve Your Life:
1. They Enhance Your Existing Code, Increasing Confidence

Imagine a function who’s task is to retrieve a list of frogs from an API, uses the returned list to calculate the average width of tongues of the frogs and returns the result.
An example would be something like:
As it is now, we are restricted to only returning a number. But what if there was a way to transform it into an object without changing the original function?
The enhancement here is having the ability to pass in additional options to customize and transform the output for better control: