Quantcast
Viewing all articles
Browse latest Browse all 11

JS Lint: Missing ‘new’ prefix when invoking a constructor

When you have a function that starts with a capital letter, JS Lint (and JS Hint) will consider it a constructor since that is the traditional constructor syntax. JS Lint will throw the error “JS Lint: Missing ‘new’ prefix when invoking a constructor.” It’s generally best practice to start your function names with a lowercase letter unless you are creating a constructor. This will keep JS Lint from barking at you about it.

var BadFunctionName = function(){
// DO STUFF
}

var goodFunctionName = function(){
// DO STUFF
}


Viewing all articles
Browse latest Browse all 11

Trending Articles