链式调用

方法1: 

var obj = { a: function() { console.log("a"); return this; }, b: function() { console.log("b"); return this; }, }; obj.a().b();

方法二:
function Test() {
    console.log('初始化')
}
Test.prototype.method = function(param) {
    console.log(param)
    return this
}
let cl = new Test()
//由于new 在实例化的时候this会指向创建的对象, 所以this.method这个方法会在原型链中找到。
cl.method('第一次调用').method('第二次链式调用').method('第三次链式调用')
 
原文地址:https://www.cnblogs.com/zxm1993/p/14081207.html