JavaScript naming conventions and coding guidelines

I’ve recognized that I’m sometimes not following the general rules when writing JavaScript code. *ashamed*

For example:

– Using a lot of C# conventions, which are wrong in JS,

– Putting accidentally variables and functions in the global scope,

– Pascal and Camel casing is mixedly used for naming variables and functions all over our applications,

– Using “==” instead of strict equality operator (“===”),

– Etc.

I came a long way from the complete noob I once was but I decided to invest more time in studying the Javascript naming conventions and coding guidelines. These two links were very helpful:

I’ve also tested our JavaScript code with JSLint and did some major refactoring to fix the errors. We are actually working on integrating this component into the build or, at least, to have a policy for it. We couldn’t really manage to put it in the build just yet and we have some issues setting up the policy so, if you’ve done this before, please tell me how! Smile

I think taking these steps will not only improve code readability, performance and avoiding future errors, but it will also help new team members understand our code better.

Additionally, I recommend any kind of resources by Douglas Crockford, especially but not only: “JavaScript: The Good Parts”, articles, videos – see JavaScript: The Good Parts by Douglas Crockford or just search on YUI Theater for videos by Douglas Crockford.

I’m continuously improving my JavaScript knowledge so any other suggestions are more than welcome! Winking smile