Book Image

Mastering JavaScript Functional Programming

By : Federico Kereki
Book Image

Mastering JavaScript Functional Programming

By: Federico Kereki

Overview of this book

Functional programming is a programming paradigm for developing software using functions. Learning to use functional programming is a good way to write more concise code, with greater concurrency and performance. The JavaScript language is particularly suited to functional programming. This book provides comprehensive coverage of the major topics in functional programming with JavaScript to produce shorter, clearer, and testable programs. You’ll delve into functional programming; including writing and testing pure functions, reducing side-effects, and other features to make your applications functional in nature. Specifically, we’ll explore techniques to simplify coding, apply recursion for loopless coding, learn ways to achieve immutability, implement design patterns, and work with data types. By the end of this book, you’ll have developed the JavaScript skills you need to program functional applications with confidence.
Table of Contents (22 chapters)
Title Page
About the Author
About the Reviewer
Customer Feedback
Connecting Functions - Pipelining and Composition
Answers to Questions

Partial application

The second transformation that we will be considering lets you fix some of the parameters of the function, creating a new function that will receive the rest of them. Let's make this clear with a nonsense example. Imagine you have a function with five parameters. You might want to fix the second and fifth parameters, and partial application would then produce a new version of the function that fixed those two parameters but left open the other three for new calls. If you called the resulting function with the three required arguments, it would produce the correct answer, by using the original two fixed parameters plus the newly provided three.


The idea of specifying only some of the parameters in function application, producing a function of the remaining parameters is called projection: you are said to be projecting the function onto the remaining arguments. We will not use this term, but we wanted to cite it, just in case you happen to find it somewhere else.