call - JSLint 坚持 "Unexpected ' 调用'"

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

}

是错的。好吧,无论如何,出乎意料。我一生都无法弄清楚为什么,代码有问题吗?它似乎有效,但我担心意外行为。

最佳答案

警告的原因是以下行:

this._constructTable.call(this, tableArray);

这个结构似乎在很大程度上毫无意义——你正在调用 _constructTable this 上下文中的方法,如果您通过普通调用表达式调用它,它将与调用它的上下文相同。 JSLint 正是期待:
this._constructTable(tableArray);

关于call - JSLint 坚持 "Unexpected ' 调用'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17170148/

相关文章:

javascript - 解决Jslint警告

javascript - "combine this with previous var . . ."声明

javascript - JSLint : Expected '!!' and instead saw '?'

javascript - 在 Javascript 中用 if 语句包装 For in 循环——遍历数组

r - R中plot函数如何查找regsubsets?

android - 通过指定的 SIM 从 android 调用

function - 在不添加该路径的情况下调用不在 Matlab 路径上的函数

javascript - 'new function(){...}' 上的 JSLint 错误,但为什么呢?如果我想要匿名闭包,有没有更好的方法?

java - 当我在 eclipse 中测试 java GUI 时,如何知道调用了哪个方法/类?

javascript - Javascript函数调用在IE和Chrome中不起作用