How to fix JSLint “missing new” error

老子叫甜甜 提交于 2019-12-05 11:13:14

问题


Code below passed through JSLint causes an error:

Problem at line 8 character 9: Missing 'new'.

ResizeGrid();

How to fix?

"use strict";

var ResizeGrid;

function t() {
    var x;
    if (x) {
        ResizeGrid();
    }
}

回答1:


Tick Tolerate uncapitalized constructors or rename to resizeGrid(); to prevent lint from assuming its a function constructor (although calling an undefined var like that will raise other errors).




回答2:


You should name functions with a lower case initial letter, unless they are intended as constructors. If they are intended as constructors, you should be calling them with new.



来源:https://stackoverflow.com/questions/7568929/how-to-fix-jslint-missing-new-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!