on: function(event, fn) { var handles = this._handles || (this._handles = {}), calls = handles[event] || (handles[event] = []); // 找到对应名字的栈 calls.push(fn); return this; }在这个函数中,return this到底是什么意思,调用这个函数的时候并没有和赋值语句一起使用啊?请问为何还要使用?
1 回答
![?](http://img1.sycdn.imooc.com/5458657e000125a302200220-100-100.jpg)
天涯尽头无女友
TA贡献1831条经验 获得超9个赞
如果你知道jq的链式写法, 就知道为什么要return this了...
var a = { b: function(bb) { console.log(bb) return this; }, c: function(cc) { console.log(cc) return this; }, d: function(dd) { console.log(dd) return this; } } a.b(1).c(2).d(3);// 1// 2// 3// Object {}
添加回答
举报
0/150
提交
取消