var testFn = function () {} testFn.prototype = { fn1: function () { console.log(this); console.log('fn1'); return this; }, fn2: function () { console.log(this); console.log('fn2'); return this; }, fn3: function () { console.log(this); console.log('fn3'); return this; } }; var testFn = new testFn(); testFn.fn1().fn2().fn3();
链式调用本质是: 实例化的函数调用原型对象上的方法;