We will learn how to jquery style chain functions ( Methods) using pure javaScript. in Jquery we can do $(‘.class’).addClass(‘new’).removeClass(‘old’). we can achive similar chaining using pure javascript.
Method chaining, also known as named parameter idiom, is a common syntax for invoking multiple method calls in object-oriented programming languages. Each method returns an object, allowing the calls to be chained together in a single statement without requiring variables to store the intermediate results.
javascript advance tutorials
javascript function chaining
jquery like function chaining
javascript how to chain functions
java script function chaining
method chaining
chaining module method calls
method cascading
ECMAScript 5
ECMAScript6
Original source
33 responses to “javaScript Method chaining tutorial ( function chaining)”
Note the shorthand instead of "{add: add, substract: substract, print: print};" you can now write
return {add, substract, print}; And thanks for this clear demonstration.
Hi, I liked your tutorial. Is there other way than just return{add:add, substract:st…} and why didn't you use new obj()??? Could you please guide me π
very nice
Very nice explanation.. hurrayππ
javaScript Method chaining tutorial ( function chaining) what you want to explain in this video did get it please tell me
this guy is on point! great teacher
Hi, I have tried in my localhost, but i didn't get any console output, please guide me
very nice explanation.
You are very good at explaining things.
why return "this" ?
Is it same like event chaining ? Kindly reply
Thanks great explanation, easy to follow
You should learn vi!
in the first example what is the point of passing the argument if I is already available in the scope? is this just best practices?
i must very interesting tutorials , you simply made it so easy to understand ,thanks a lot
really helpful, nice one
Can you make tutorial about functions that return functions?there is no videos like that, but it is something?isn't it?
are bhai substract nahi, Subtract π
awesome sir..your advanced js tutorial
What if you wanna add error handling to that? Like what you do with promises with catch, in case one of the chain links failed?
This is very helpful, thanks for sharing your knowledge!
very very good example .
Not only method chaining
the example at the end is very useful for writing a class with private fields and public methods..
Great video. FYI, it's "subtract".
thanks for a great tutorial..it completely makes sense for me ..
Hi, Thank you for the wonderful video. Can you please share your jsFiddle link here.
Thanks,
I have always added new when creating the object. How did you get away with removing the new at 10:08 Can you please elaborate. Thanks π
This was extremely useful. Thank you for the straighforward and great tutorial.
π
This is great! Illustrates Method Chaining clearly!
it seems that the returned object is nothing but bunch of functions,these bunch of functions share the out parameter i,they can modify this i and return the object itself,which was cool, thanks sith!
Very helpful. I am newbie to java script. Thanks for the video.
Nicely done. A very good use of 12 minutes for beginning JS programmers.
You don't create a closure, you use a closure because closure is a feature of the language.
Very informative video!