Book Image

Advanced JavaScript

By : Zachary Shute
Book Image

Advanced JavaScript

By: Zachary Shute

Overview of this book

If you are looking for a programming language to develop flexible and efficient applications, JavaScript is an obvious choice. Advanced JavaScript is a hands-on guide that takes you through JavaScript and its many features, one step at a time. You'll begin by learning how to use the new JavaScript syntax in ES6, and then work through the many other features that modern JavaScript has to offer. As you progress through the chapters, you’ll use asynchronous programming with callbacks and promises, handle browser events, and perform Document Object Model (DOM) manipulation. You'll also explore various methods of testing JavaScript projects. In the concluding chapters, you'll discover functional programming and learn to use it to build your apps. With this book as your guide, you'll also be able to develop APIs using Node.js and Express, create front-ends using React/Redux, and build mobile apps using React/Expo. By the end of Advanced JavaScript, you will have explored the features and benefits of JavaScript to build small applications.
Table of Contents (9 chapters)

Function Composition


Function composition is the final key to understanding functional programming. Function composition takes many of the concepts learned in this chapter and nicely wraps them in the core of functional programming. The widely used definition of function composition is that function composition is a mathematical concept that allows you to combine multiple functions to create a new function. This definition tells us what function composition is, but doesn't really give us any sense of how to compose functions or why we need to use it.

As we know from the definition, function composition is the act of combining functions to create a new one. What does this mean exactly? In mathematics, we often see functions composed like so: f(g(x)). If this is not familiar to you, in the expression f(g(x)), we pass the variable x into the function g and then pass the result of g(x) into the function f. The expression f(g(x)) is evaluated from the inside out, from right to left, in the order...