Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSLint insists that "Unexpected 'call'"

Tags:

jslint

call

JSLint insists that there's something wrong with this use of .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);

}

Is wrong. Well, Unexpected, anyway. I just can't for the life of me figure out why, is there something wrong with the code? It seems to work, but I'm worried about unexpected behavior.

like image 783
Fenixp Avatar asked Jun 18 '13 13:06

Fenixp


1 Answers

The cause of the warning is the following line:

this._constructTable.call(this, tableArray);

This construct appears to be largely pointless - you are calling the _constructTable method in the context of this, which would be the same context it would be called in if you called it via a normal call expression. JSLint is expecting exactly that:

this._constructTable(tableArray);
like image 122
James Allardice Avatar answered Sep 28 '22 17:09

James Allardice