Skip to content

Commit

Permalink
Adds contributors.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Aug 2, 2011
1 parent 371ed91 commit 838569c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contributors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Rick waldron
* Mathias Bynens
* Schalk Neethling
36 changes: 36 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,42 @@ Projects _must_ include some form of unit, reference, implementation or function

6. <a name="naming">Naming</a>


You are not a human code compiler/compressor, so don't try to be one.

The following code is an example of egregious naming:

```javascript
function q(s) {
return document.querySelectorAll(s);
}
var i,a=[],els=q("#foo");
for(i=0;i<els.length;i++){a.push(els[i]);}
```

Without a doubt, you've written code like this - hopefully that ends today.

Here's the same piece of logic, but with kinder, more thoughtful naming (and a readable structure):

```javascript

function query( selector ) {
return document.querySelectorAll( selector );
}

var idx = 0,
elements = [],
matches = query("#foo"),
length = matches.length;

for( ; idx < length; idx++ ){
elements.push( matches[ idx ] );
}

```

A few additional pointers...

```javascript

`dog` is a string
Expand Down

0 comments on commit 838569c

Please sign in to comment.