// include a space after most keywords (eg var, if, else, for, return) var foo = "bar"; // include a space around operators foo === "bar"; foo += "qux"; // put a space after most closing parentheses // indent within if statements if (foo === "bar") { alert("baz!"); } // indent within loops for (var i = 0; i < 3; i++) { alert(i); } // indent within functions function doSomething() { alert("do something you fool!"); } // always indent two spaces at a time. never more, never less. // don't include a space between a function and the opening parentheses enclosing its arguments alert("look, no space!");