Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable naming conventions other than trailing underscore [duplicate]

I'm reformatting a plug-in so that it passes JSLint. Plug-in uses trailing underscores to name local variables, like so:

var __slice = [].slice,
    __indexOf = [].indexOf

JSLint does not like this. What's another easily recognisable convention for naming these, that JSLint won't object to?

like image 691
Ila Avatar asked Apr 18 '26 20:04

Ila


1 Answers

Quoting from Douglas Crockford, the guy who invented JSLint:

Do not use _ (underbar) as the first character of a name. It is sometimes used to indicate privacy, but it does not actually provide privacy. If privacy is important, use the forms that provide private members. Avoid conventions that demonstrate a lack of competence.

Most variables and functions should start with a lower case letter.

Taken from Code Conventions for the JavaScript Programming Language .

You can look at Private Members in Javascript to see what he meant by use the forms that provide private members.

like image 147
Ibrahim Najjar Avatar answered Apr 21 '26 09:04

Ibrahim Najjar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!