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)

Higher Order Functions


As we learned in the first topic, a higher order function is a function that either takes another function in as an input argument or returns another function as the return value. Nearly all asynchronous code in JavaScript makes use of higher order functions by passing callback functions in as input arguments. Aside from their prolific use in JavaScript, higher order functions are a key part of Functional Programming and are used for three key benefits: abstraction, utilities, and complexity reduction.

Higher order functions are very important for abstraction. Abstraction is a way to hide the internal workings or details of a procedure. For example, consider the process of cooking a meal from a recipe. A recipe may require you to chop a food item. What is chopping? It is an abstraction of an action. The action and steps to complete the action are to take a knife, place it over the food item, and press downward. Then, move the knife a short distance along the food item...