Skip to content

Instantly share code, notes, and snippets.

@michaelrkn
Created August 10, 2013 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelrkn/6202011 to your computer and use it in GitHub Desktop.
Save michaelrkn/6202011 to your computer and use it in GitHub Desktop.
epicodus javascript spacing guide
// 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!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment