My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

How do I create a function/object which supports chaining?

Umesh Kumar's photo
Umesh Kumar
·Apr 26, 2018

Let's assume I have three functions one(), two(), three(), etc. I want these function to support chaining.

Example :

one().two().three();

or

three().two().one();

Something similar to calling many APIs in JavaScript:

fetch().then().then()