JSLint坚持认为“意外'呼叫'”

时间:2013-06-18 13:28:11

标签: call jslint

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);

}

错了。好吧,无论如何,意外。我只是不能为我的生活弄清楚为什么,代码有什么问题吗?它似乎工作,但我担心意外的行为。

1 个答案:

答案 0 :(得分:10)

警告的原因如下:

this._constructTable.call(this, tableArray);

这个结构似乎毫无意义 - 你在_constructTable的上下文中调用this方法,如果你通过普通调用调用它,它将被调用的相同上下文表达。 JSLint正好期待:

this._constructTable(tableArray);