Fork me on GitHub

JSLint Error Explanations

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


Unexpected dangling '_' in '{a}'

When do I get this error?

JSLint will throw the "Unexpected dangling '_' in '{a}'" error when it encounters an identifier that begins or ends with the underscore character. JSHint will throw this error in the same situation, but only if the nomen option is set to true. In the following example we use several such identifiers:

Why do I get this error?

This error is raised to highlight a lack of convention. Your code will run without error if you do not change it, but could be confusing to other developers, and could also indicate a lack of understanding of the language.

Identifiers prefixed with the underscore character are often used to indicate a private variable. Since JavaScript doesn't have a real notion of "private", this can be misleading.

If you're using JSLint, you can fix the error by setting the nomen (short for nomenclature) option to true. Conversely, if you're using JSHint, you can simply remove the same option:

Alternatively, you can simply remove the underscore character from the start or end of your identifiers (note that use of this character elsewhere in identifiers is accepted):


comments powered by Disqus