Skip to content

Commit

Permalink
adding in a great quote
Browse files Browse the repository at this point in the history
  • Loading branch information
aconbere committed Apr 19, 2010
1 parent 12ef6dd commit 844a3ba
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions readme.mkd
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Elements of JavaScript Style #

> "Break any of these rules sooner than say anything outright barbarous."
> - George Orwell
We start with the assertion that there is a great language inside of JavaScript. But that many people struggle to find their way to it. The most common resources for learning were written in the dark ages of the web, and advocate a style and structure that is non-conducive to quality readable code.

The goal is to fill a gap in the JavaScript community, to codify common styles, to point out common anti-patterns to those learning the language for the first time, and to solidify a set of common styles for those who have been at this for a while longer.
Expand Down Expand Up @@ -109,6 +112,25 @@ brace. Previous rules hold.
return "orange";
}

### One Line Ifs ###

Never leave the optional braces off of a one line if.

*Good:*
if(condition) { return "apple"; }
if(condition) {
return "apple";
}

*Bad:*
if(condition) return "apple";
if(condition)
return "apple";

> Leaving off the braces on one line ifs makes refactoring your code much more
> difficult. When adding more behavior to the conditional the braces will have
> to be added in, also it can cause confusion when moving the block.
## Naming ##

Variables and methods should be __camelCase__.
Expand Down

0 comments on commit 844a3ba

Please sign in to comment.