怎么实现链式调用

var user = function(name, age) {
      this.name = name;
      this.age = age;
    };
    user.prototype.getName = function() {
      console.log(this.name);
      return this;
    };
    user.prototype.getAge = function() {
      console.log(this.age);
      return this;
    };
    var user1 = new user("zjf", 22);
    user1.getName().getAge()

 只需要在方法后直接return出this即可

原文地址:https://www.cnblogs.com/Ewarm/p/13126236.html