Recently for work as part of our sporadic push to create coding standards, I contributed by writing a draft of our JavaScript coding guidelines document. I've probably been the most active developer at work JavaScript and Ajax, and this combined with me having recently finished Douglas Crockford's excellent Javascript: The Good Parts book made me the most likely candidate to do so. Here is what I came up with.
The document is written from an ASP.NET developer's perspective, and since the direction for JavaScript that Microsoft is pushing now is a mix of its own ASP.NET Ajax library and jQuery, those are the libraries I focused on. Also, I didn't write much into strict coding standards per se (i.e. variables should be named and cased this and this way...), but instead focused on general guidance for the JavaScript language and some key best practices.
Here are several resources I used to come up with the standards (these are also in the references section at the end of the document):
- JavaScript: The Good Parts, by Douglas Crockford.
- A lecture related to the book (and which contains a large portion of the book's content for free) can be found here.
- Code Conventions for the JavaScript Programming Language.
- Block Statement.
- With Statement Considered Harmful.
- WestWind Ajax Toolkit.