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


3.1 Uninitialized object? React+Redux programmers usually code action creators to simplify the creation of actions that will later be processed by a reducer. Actions are objects, which must include a type attribute that is used to determine what kind of action you are dispatching.  The following code supposedly does that, but can you explain the unexpected results?

     const simpleAction = t => {
         type: t;


3.2. Are arrows allowed? Would everything be the same if you defined listArguments() and listArguments2() using arrow functions, instead of the classic way we used, with the function keyword?

3.3. One liner. Some line-of-codes-thrifty programmer suggested rewriting doAction2() as a one-liner... though formatting doesn't let it look so! What do you think: is it correct or isn't it?

     const doAction3 = (state = initialState, action) =>
         (dispatchTable[action.type] &&