dispose: function() {
    var disposer;
    while (disposer = this._disposers.shift()) { // expected a conditional expression and instead saw an assignment.
      disposer();
    }
  },
jshint不满意在disposer循环中分配了while

有什么方法可以保持这种逻辑并使它对jshint友好?

最佳答案

除非我错过了什么...

dispose: function() {
    var disposer = this._disposers.shift();
    while (disposer) {
        disposer();
        disposer = this._disposers.shift();
    }
},

您可能还想增强条件:
while (typeof disposer === 'function') {

工作示例:http://jsfiddle.net/DPNYq/

09-11 05:00