-
Notifications
You must be signed in to change notification settings - Fork 0
JavaScript Style Guide
80-character width lines. Newline at the end of each file. Use 2 spaces to indent.
Brace formatting should be on the next line for a named function and on the same line for a closure.
var doThing = function()
{
var x = function(arg){
attack(x);
};
}Braces also go on the same line for if statements.
if(test === 10){
return true;
}
else{
return false;
}Use /* comment */ for multi-line comments. Use // otherwise.
Use semicolons. When working with callbacks, put the brace on the same line as the paren:
function setCallback(obj)
{
obj.onComplete(function(data){
send(data);
});
}We use semicolons everywhere.
E V E R Y W H E R E.
Never rely on the implicit semicolon insertion.
Never use ==, always use ===.
Single-letter variable names are fine if it is blatantly obvious what they are. They are almost never that obvious.
If you have to write something nasty (it's JavaScript, it happens), write a little apology and explanation. If it's really gross, and you can prove that it's the best way to do it, we'll buy you a beer (or Soda of your choice) as a way to help you deal with the pain.
Style Guides
Features
- Frontpage
- About pages
- Help pages
- Uploading Images
- Image pages
- Image comments
- Image search
- Image tagging
- Image collections
- Curating collections
- Creators
- Commissions
- Image of the Day
- Favorites
- User profiles
- User settings
- Error messages
- Reporting
- Admin console
- API
- Notifications
Mockups
Roadmap
Notes