Point-Free JavaScript

Composable array method usage with functional programming

Photo by Bannon Morrissy on Unsplash

JavaScript started to gain mainstream attraction around 2009. Around that time, we got the high-performance v8 engine. A few months later, Node.js convinced us to take JavaScript seriously and then AngularJS stepped up front-end development to another level.

But what we are interested in in this story are the functional array methods introduced with ES5.

In 2009, JavaScript had some improvements like strict mode, JSON support, and functional array methods with ES5. Years later, React kicked in and introduced JavaScript developers to the functional programming paradigm.

More and more people started to use array methods like map , filter , reduce , every , some , etc.

The advantages of using these methods are immutability and enable coders to write declarative code. All those are great but the question is: “Do we use these methods effectively?”

I will show you how to get the most out of these methods using functional programming technics. Also, I will use close-to-real-world examples. I don’t believe in counter or foo-bar examples.

For the sake of simplicity, I’m not going to cover every detail or edge case. I’m going to hardcode some parts like parameters.