JSLint 坚持认为 .call 的这种用法有问题:
function GridView(tableArray, tableId, multiselect) {
"use strict";
if (multiselect == undefined) {
this.multiselect = false;
} else {
this.multiselect = multiselect;
}
this.tableID = tableId;
this.propertiesArr = [];
this.tableHTML = undefined;
this.oTable = undefined;
this._constructTable.call(this, tableArray);
}
是错的。好吧,无论如何,出乎意料。我一生都无法弄清楚为什么,代码有问题吗?它似乎有效,但我担心意外行为。
最佳答案
警告的原因是以下行:
this._constructTable.call(this, tableArray);
这个结构似乎在很大程度上毫无意义——你正在调用
_constructTable
this
上下文中的方法,如果您通过普通调用表达式调用它,它将与调用它的上下文相同。 JSLint 正是期待:this._constructTable(tableArray);
关于call - JSLint 坚持 "Unexpected ' 调用'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17170148/