Skip to content

Instantly share code, notes, and snippets.

@michaelrkn
Created August 10, 2013 20:31
Show Gist options
  • Select an option

  • Save michaelrkn/6202011 to your computer and use it in GitHub Desktop.

Select an option

Save michaelrkn/6202011 to your computer and use it in GitHub Desktop.

Revisions

  1. michaelrkn created this gist Aug 10, 2013.
    29 changes: 29 additions & 0 deletions spacing.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    // 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!");