Object Oriented JavaScript Tutorial #7 – Method Chaining




Hey gang, in this Object Oriented JavaScript tutorial I’ll explain what method chaining is, and how we can set this up to work by editing the return value of the methods inside our User class.

🐱💻 Course Links:

– VS Code editor – https://code.visualstudio.com/
– GitHub repository (course files) – https://github.com/iamshaunjp/object-oriented-js
– JavaScript for Beginners – https://www.youtube.com/watch?v=qoSksQ4s_hg&list=PL4cUxeGkcC9i9Ae2D9Ee1RvylH38dKuET

🤑 Donate @ https://www.paypal.me/thenetninja

🎓Find me on Udemy @ https://www.udemy.com/user/47fd83f6-5e4a-4e87-a0f0-519ac51f91b6/

👾 Video thumbnail artwork by PixelSwish @ https://www.youtube.com/channel/UCGKSD3mitWl5UpMxZzaIrRA

Original source


26 responses to “Object Oriented JavaScript Tutorial #7 – Method Chaining”

  1. I did enhance the code a little bit, I wonder if I could make a for loop and I was inspired by "and" function in browser object :

    //add to User class
    and(cb){
    cb(this);
    return this;
    }

    //useage
    var user1 = new User('xxx@yyyy.com', 'bander');

    user1.login().and(
    function (user) {
    for (var i = 0; i < 10; i++) {
    user.updateScore()
    }
    }).logout();

  2. hey Shaun, can you give me an example that when we will use this method chaining in our projects ? and what is the usage of it ?i mean aside of chaining methods what is the real purpose of using it ? how it can be useful to use it ?

Leave a Reply