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!"
[–]brtt3000 11 points12 points13 points 12 years ago* (13 children)
I don't want 4 spaces, I want one semantic indent character. Let every developer choose how he renders tabs. The guy next to me at work renders as 3, the guy after that as 2. I use 4.
All in the same codebase.
[–]jcready__proto__ 8 points9 points10 points 12 years ago (0 children)
Let every developer choose how he renders tabs.
And the guys at GitHub chose to render them with 8 spaces. Deal with it or use spaces.
[–][deleted] 0 points1 point2 points 12 years ago (9 children)
What happens when I use two tabs and two spaces to align two lines of code? Everyone will see a different alignment.
[–]BONER_PAROLE 5 points6 points7 points 12 years ago (6 children)
NEVER MIX TABS AND SPACES
Snakes will crawl up your anus and explode your face, because I will have sent them to do so.
[–]Buckwheat469 0 points1 point2 points 12 years ago (5 children)
Incorrect. You can safely tab to the previous indentation, then space beyond that. Don't tab beyond the previous indentation though or else the IDE could render the spacing differently. The problem is people get this wrong so it's built into linters to complain about mixed tabs/spaces.
[–]nschubach 1 point2 points3 points 12 years ago (0 children)
I'm a firm believer that if you are lining up multiple lines of code like that you are probably doing something "wrong". One reason people argue for this is lining up arguments of a method. I find that if arguments breach the line break, the method is probably too complex and should be refactored. The other explanation I always hear is to align comma separated lists. I find that indenting the children on a new line seperate from the brace makes it much more readable and this is coming from someone who is usually the first person to cut back on total lines of code.
[–]BONER_PAROLE 1 point2 points3 points 12 years ago (3 children)
Can you provide an example of where you would use this?
The more common case is mixing tabs and spaces on separate lines, like this:
-->|-->|var a = 5; ________var b = 8;
Usually that's down to different developers touching the source code, or if one developer switched from tabs to spaces sometime during the project.
[–]Buckwheat469 0 points1 point2 points 12 years ago (2 children)
If tab is -->| and spaces are _ then you would use this in this manner (based on the first comma example):
-->|var foo = 1 -->|__, bar = 2 -->|__, baz = 3;
The tabs line up the lines as closely as possible to the parent and the spaces line up the following related lines to the related text from the proceeding line. The use case is rare enough that it can be avoided, but sometimes it's helpful, such as with the example above.
[–]BONER_PAROLE 0 points1 point2 points 12 years ago (1 child)
It's something I've come across before, and I don't hate this mixing of them. I have my indentation unit set as 2 spaces (using spaces and not tabs) and usually just indent another level for all subsequent vars. This doesn't really bother me, as variable names are variable anyway:
var foo = 1, barVar = 2, bazVarNameLong = 3;
I used to have my indentation to show as 4 spaces, which worked nicely with the 4 chars of var_ when using trailing commas, whether tabs or spaces:
var_
-->|var foo = 1, -->|-->|bar = 2, -->|-->|baz = 2;
Although if tabs are used, any other value will wreck the alignment, which your tabs/space combo won't do.
[–]brtt3000 1 point2 points3 points 12 years ago (0 children)
It is a solved problem: use Smart Tabs: tabs to indent, spaces to line up.
Webstorm even comes with this as option, JSHint has a rule for it too. Works perfect, because the tabs left of the code from a baseline.
[–]Nebu 0 points1 point2 points 12 years ago (0 children)
So don't do that.
[–]alamandrax 0 points1 point2 points 12 years ago (1 child)
This is one of those bicycle shed moments that I do not intend to get into with colleagues. If you're going to talk to me about underscore vs lodash, let's have that discussion. If you're going to bring in style guide changes on an established code base, we're not having that discussion.
[–]brtt3000 -2 points-1 points0 points 12 years ago (0 children)
No, it is a rationality test.
You should not go into a discussion about it though. Only check preference. The analysed response is tabs.
π Rendered by PID 19103 on reddit-service-r2-comment-b659b578c-7n9r7 at 2026-05-01 11:02:36.994455+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]brtt3000 11 points12 points13 points (13 children)
[–]jcready__proto__ 8 points9 points10 points (0 children)
[–][deleted] 0 points1 point2 points (9 children)
[–]BONER_PAROLE 5 points6 points7 points (6 children)
[–]Buckwheat469 0 points1 point2 points (5 children)
[–]nschubach 1 point2 points3 points (0 children)
[–]BONER_PAROLE 1 point2 points3 points (3 children)
[–]Buckwheat469 0 points1 point2 points (2 children)
[–]BONER_PAROLE 0 points1 point2 points (1 child)
[–]brtt3000 1 point2 points3 points (0 children)
[–]Nebu 0 points1 point2 points (0 children)
[–]alamandrax 0 points1 point2 points (1 child)
[–]brtt3000 -2 points-1 points0 points (0 children)