Created
August 10, 2013 20:31
-
-
Save michaelrkn/6202011 to your computer and use it in GitHub Desktop.
epicodus javascript spacing guide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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