Let’s say I have some JavaScript that looks like this:
function A() {
var MyVar, SomeParameter;
// do work
MyVar = FunctionB(SomeParameter);
}
JsLint says I’m Missing 'new'. at the line MyVar = FunctionB(SomeParameter);
Why should I rewrite as MyVar = new FunctionB(SomeParameter); Is there going to be any benefit?
It is the convention that constructors (eg:
Array,Object) are starting with a capital.JSLint complains, because it thinks that you’re trying to use a constructor, without
newkeyword. To fix the problem, start your function with a non-uppercase character.