Chainable interfaces make your code readable and, arguably, your life more enjoyable.
Chainable interfaces are those series of methods that you see chained to an object. You can use them for objects where “relevant”.
Commonly used functions
It is common to see methods chained to one another. The chaining works from left to right, with results from the left-side of the function passed to the right in sequence.
|
|
Custom Objects
One of the ways of demonstrating chainable interfaces for our own objects is by defining a function, and defining props and prototypes for the function.
We will define a function and the prototypes of that function.
|
|
Now, I can use chained methods to set values.
|
|