Note: This is part of the “Composing Software” series on learning functional programming and compositional software techniques in JavaScript ES6+ from the ground up. Stay tuned. There’s a lot more of this to come!< Previous | << Start over at Part 1 | Next >

For those unfamiliar with JavaScript or ES6+, this is intended as a brief introduction. Whether you’re a beginner or experienced JavaScript developer, you may learn something new. The following is only meant to scratch the surface and get you excited. If you want to know more, you’ll just have to explore deeper. There’s a lot more ahead.

The best way to learn to code is to code. I recommend that you follow along using an interactive JavaScript programming environment such as

When unit testing real-world code, there are many situations that make tests hard to write. How do you check if a function was called? How do you test an Ajax call? Or code using setTimeout? That’s when you use test doubles — replacement code that makes hard to test things easy to test.

More from this author

For many years, Sinon.js has been the de-facto standard in JavaScript tests for creating test doubles. It’s a must-have tool for any JavaScript developer writing tests, as without it, writing tests for real applications would be nigh impossible.

Functional programming in JavaScript has become an increasingly sought after skill, and for a good reason. By employing the proper functional programming concepts, users can eliminate problems that come with a global scope, and create applications using same bits of reusable code. Those interested in learning more about FP should check out Master the JavaScript Interview: What is Functional Programming by Eric Elliott, as it does a fantastic job of explaining the topic. Today, we’re going to focus on currying in JavaScript, and take a first-hand look at how we can use curried functions to compose new functions.