Thursday, February 16th, 2006
JavaScript Style Guide
<>p>Ah the hours of arguing over coding style. We have all been there.It starts with:
Should our team/company have guidelines?
And then it gets to:
{ braces MUST be on the same line, are you NUTS!!!
It is often good to look at what others are doing, and the Dojo Toolkit has their
Javascript Programming Conventions Guide published.
It is very detailed, going over naming conventions, file conventions, variable usage, code layout, whitespace, and comments.
Related Content:












[...] Ajaxian.com have reported on Dojo Toolkit’s new JavaScript style guide. Ah the hours of arguing over coding style. We have all been there. [...]
Guidelines are very important and overall Dojo’s are very good. We just need to convince Alex to allow us to put an extra space after a function definition. :P
function something() {vs.
function something(){ //(makes my head hurt)I think the very first sentence of the guide takes care of that. :-)
Dan, I won’t fight you too hard in your modules ;-)
I would like to extend this suggestion to have a space in front of all opening braces: “if (..) {“, “while(..) {“, etc. Otherwise, very nice guide!
Only someone who is utterly inexperienced at working with others code would even consider suggesting putting the { on the same line. { and } must line up – this is a huge help in finding missing block structure.
I say this from 30 years of experience of programming in languages that use { } and from having tried all the styles.
[...] JavaScript Style Guide [...]
[...] Javascript Style [...]
I agree with xman { should not be on same line. They should be below and line up
{
so it
is easy
to follow
a
block;
}
Looks like they’ve moved it here sometime in the last 2 years:
http://dojotoolkit.org/developer/StyleGuide