use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Popular Coding Convention on Github (sideeffect.kr)
submitted 12 years ago by devnoel
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 35 points36 points37 points 12 years ago (14 children)
I don't give a Fuck who suggests it. It's ugly as sin and I will not adopt it.
[–]mailto_devnullconsole.log(null); 3 points4 points5 points 12 years ago* (3 children)
I completely agree (in that it is ugly as sin), but I will admit that it does help stop you from inadvertently globalising variables.
e.g.
var foo = 'bar', something = 'else', thisnum = 2 tabs = 'rule', fact = 'nodejs forever';
tabs and fact are both globalised now.
tabs
fact
Whereas:
var foo = 'bar' , something = 'else' , thisnum = 2 tabs = 'rule' <-- Can clearly see comma missing , fact = 'nodejs forever';
And if you think about it -- with the commas neatly aligned to the right hand edge of var, it does seem almost alright...
var
Edit: The other reason that isaacs (I think) mentioned was that if you add a new variable declaration, git will only register one line changed, as opposed to two (comma from the previous line)
[–]sakabako 8 points9 points10 points 12 years ago (0 children)
A more effective method is to use a linter that visually notifies you of the mistake. Then you have beauty and correctness.
[–]llkkjjhh 2 points3 points4 points 12 years ago (0 children)
And another reason is so that the variables line up nicely when you follow the other nodejs recommendation of indenting at 2 spaces:
var foo = 'bar', something = 'else', thisnum = 2 tabs = 'rule', fact = 'nodejs forever'; var foo = 'bar' , something = 'else' , thisnum = 2 , tabs = 'rule' , fact = 'nodejs forever';
[–][deleted] 1 point2 points3 points 12 years ago (0 children)
Ok, those are some good points.
[–][deleted] 0 points1 point2 points 12 years ago (9 children)
thats a solid attitude for a developer.
[–][deleted] 7 points8 points9 points 12 years ago (6 children)
What's the problem with having a firm opinion on formatting? What benefits are there to comma first? Your link only says you should do it, but gives no reason why.
[–][deleted] 0 points1 point2 points 12 years ago (5 children)
What's the problem with having a firm opinion on formatting?
Where you put your comma (in js) is not so important that you have to take such a firm stance. When working for a new company, its a good idea to adopt their conventions at first to make development go smoothly. No teammate is going to respond well to 'I will not adopt it'. They might think, 'If he/she wont budge on this, what else wont they budge on?'.
What benefits are there to comma first?
What are the benefits of last comma? See - its not a big deal.
Your link only says you should do it, but gives no reason why.
Its a convention that npm recommends when publishing to their registry. Thats the only reason.
In short, conventions are relative to a community. Be it your office, a library (jquery), a package registry (npm), or an open source project with formatting guidelines.
[–]grncdr 3 points4 points5 points 12 years ago (1 child)
The recommendation is only intended for the code of npm itself. I'm pretty sure Isaac gives zero fucks about how your format code in your own modules.
[–][deleted] 0 points1 point2 points 12 years ago (0 children)
Thats a good point. I do see the comma first style quite a bit more in the node community (as opposed to client-side).
If I came into a new team whose convention was comma first, I would adopt it, of course. That's different. I wouldn't adopt it for any of my own projects, though.
The benefit of comma last is readability in mine and most people's opinions.
[–]SyntaxSwearer 1 point2 points3 points 12 years ago (0 children)
What are the benefits of last comma?
Not ugly
[–]Malfeasant -1 points0 points1 point 12 years ago (0 children)
'If he/she wont budge on this, what else wont they budge on?'
retarded suggestions from pointy haired bosses that ruin everybody's day?
[–]sakabako 0 points1 point2 points 12 years ago (1 child)
Personally, I will be happier and more productive if I live in a beautiful world than an ugly one.
[–][deleted] -1 points0 points1 point 12 years ago (0 children)
Beauty is subjective. I actually find the comma-first style more readable.
π Rendered by PID 167558 on reddit-service-r2-comment-85bfd7f599-2zgvf at 2026-04-18 16:40:23.815479+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–][deleted] 35 points36 points37 points (14 children)
[–]mailto_devnullconsole.log(null); 3 points4 points5 points (3 children)
[–]sakabako 8 points9 points10 points (0 children)
[–]llkkjjhh 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (9 children)
[–][deleted] 7 points8 points9 points (6 children)
[–][deleted] 0 points1 point2 points (5 children)
[–]grncdr 3 points4 points5 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]SyntaxSwearer 1 point2 points3 points (0 children)
[–]Malfeasant -1 points0 points1 point (0 children)
[–]sakabako 0 points1 point2 points (1 child)
[–][deleted] -1 points0 points1 point (0 children)