JSLint insists that "unexpected call"

JSLint insists that something is 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); } 

Wrong. Well, unexpectedly, anyway. I just can’t understand for life why, is something wrong with the code? This seems to work, but I'm worried about unexpected behavior.

+6
source share
1 answer

The reason for the warning is the following line:

 this._constructTable.call(this, tableArray); 

This construct seems to be pretty much pointless - you call the _constructTable method in the this context, which will be the same context that it would be called into if you called it using a regular invocation expression. JSLint expects exactly this:

 this._constructTable(tableArray); 
+10
source

Source: https://habr.com/ru/post/947555/


All Articles