Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

coding standards

oatkiller edited this page Sep 13, 2010 · 1 revision

Variable naming

  • Name your vars like_this not likeThis.
  • unless its an exact copy of a JavaScript 1.6+ method from MDC or something else like that and that fn is named differently

Brace Style

Use 1TBS http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS

Whitespace

maximum consecutive new line chars is 1

Files

put each function in a file of its own when possible. name the file the same thing as the method in it

var

Try and use var as little as makes sense. Saves bytes an makes you think over what you’re doing. i think?

functions

  • don’t use named function declarations. http://yura.thinkweb2.com/named-function-expressions/
  • declare all functions like this


// leave a space between the identifier 'function' and the following paren.
// leave a space between the ) and the {
var my_fn = function () { ... };

  • when you execute functions, don’t leave a space between the fn identifier and the first (
  • don’t put spaces between params or commas
  • you can use line breaks and tabs tho


// like this
my_fn(1,2,3);

// not this
my_fn(1, 2, 3);

Infix operators

  • put a space on either side of any infix operators except . (i think.)

use ===, not ==

use ’ not "

i like to use " for attributes in markup

;

always use ;

Clone this wiki locally