Fix Typo #109

merged 3 commits into from Apr 14, 2012

3 participants


Fix missing comma and variable declaration.


Black gives it a better contrast.


Thanks for these updates. Merging!

@addyosmani addyosmani merged commit 6926100 into addyosmani:master Apr 14, 2012

This is incorrect. The variable is being declared in a sequence of variable declarations separated by a comma.

var base    = document.createElement('div'),
    photoEl = document.createElement('div');

is equivalent to

var base = document.createElement('div');
var photoEl = document.createElement('div');

In this commit you now have

var base = document.createElement('div'),
var photoEl = document.createElement('div');

which is bad (there is now an unnecessary var after a comma).
Either of the first two styles of variable declaration works, but var after a comma does not (try running var x=1, var y=2 in your console).

I often use the second style to declare long lists of variables with less typing and to make code more readable, e.g.:

var one   = 1
,   two   = 2
,   three = 3
,   four  = 4

Read more about the JavaScript comma operator here.


Good Catch. I am sorry I missed that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment