JavaScript Function Chaining

Function chaining under the hood

Mayank Gupta
TechnoFunnel

--

Photo by Mike Alonzo on Unsplash

The aim of this piece is to help you understand functional chaining and jQuery, and to be able to incorporate similar behavior in simple JavaScript Functions.

This piece will cover:

  1. Understanding jQuery function chaining
  2. Implementing function chaining in custom JavaScript functions

Function chaining is a pattern in JavaScript where multiple functions are called on the same object consecutively. Using the same object reference, multiple functions can be invoked. It increases the readability of the code and means less redundancy.

We need multiple functions to accomplish all the functionality related to an entity. These functions can be defined in such a way that they can be chained together to accomplish the required results.

Understanding jQuery Functional Chaining

In HTML, we deal with DOM elements. Each DOM element has multiple properties and functionalities associated with it. Let's assume that for a single DOM element we need to make multiple manipulations, like…

--

--

Mayank Gupta
TechnoFunnel

9 Years of Experience with Front-end Technologies and MEAN Stack. Working on all Major UI Frameworks like React, Angular and Vue https://medium.com/technofunnel