Fork me on GitHub

JSLint Error Explanations

JSLint will hurt your feelings. It's time to make them better!

A constructor name '{a}' should start with an uppercase letter

When do I get this error?

JSLint will throw the "A constructor name '{a}' should start with an uppercase letter" error when it encounters a function whose identifier begins with a lowercase letter and is later referenced as the operand to the new operator. In the following example we declare a "class" myClass and then attempt to instantiate it:

Why do I get this error?

This error is raised to highlight a lack of convention. It is common practice for constructor function identifiers to begin with an uppercase letter. JSLint simply enforces this convention. Here's the above snippet rewritten to pass JSLint. Notice that the only difference is the uppercase "M":

It is worth bearing in mind that this is only a convention and is not required by the language in any way. You can safely ignore this error if you prefer to name your constructor functions differently. By setting the newcap option, you can tell JSLint to allow lowercase constructors.

James Allardice

This article was written by James Allardice, an enthusiastic young JavaScript developer at Global Personals (we're looking for developers so please apply). He is passionate about writing clean, maintainable JavaScript and uses JSHint every day to help achieve this.

You can follow him on Twitter, fork him on GitHub and find him on Google+.

Proceeds generated by this site are donated to help advance other open source projects

comments powered by Disqus