Chaining Methods, also known as Cascading, is the technique of repeatedly calling different methods (or the same method) on an object in one continuous line of code. This technique is popular in jQuery and other JavaScript libraries, and it is even inherent in JavaScript’s native methods like the common String methods. It is just so lovely that we can’t resist making our own methods facilitate cascading.
We will learn that this technique is easy and effortless because it is rather straightforward to implement chainable methods in JavaScript. We only have to return this(the object we want subsequent methods to operate on) in each method. Let’s learn this baby quickly and get back to what we were doing.
Your new post is loading...