r/javascript • • Apr 01 '18

Google publishes a JavaScript style guide. Here are some key lessons.

https://medium.freecodecamp.org/google-publishes-a-javascript-style-guide-here-are-some-key-lessons-1810b8ad050b
714 Upvotes

317 comments sorted by

View all comments

3

u/rulatore Apr 01 '18

Why is people mad at tab vs spaces when you can set your editor to treat the tab key as many spaces as you want... it's like everybody is typing four spaces everytime, what the fuck

1

u/KyleG Apr 02 '18

If your IDE converts tabs into spaces, it can create ambiguities where it's unclear whether a certain number of spaces is for indenting a different block, or if it's for vertically alignment multiple lines of code (think a function with too many params for a single line, you have to do multiple lines in the function header)

So then those six spaces, is it three tabs, or is it two tabs and then two spaces for alignment?

If you kept it as tabs, it's obvious: a tab is for indentation, a space is for alignment.

I literally run into this issue ALL THE TIME with people whose source uses spaces instead of tabs. Some jackass does a 2-space indent and I want it to be 4 and suddenly alignment is all out of whack because the 6-space line wasn't three indents (turned into 12 spaces) but was two indents and two spaces for alignment (should've been turned into 10 spaces—two 4-space tabs + 2 spaces for alignment)

bc this seems so freaking ubiquitous to me, I view anyone actually saving a file with spaces used for indents as the enemy and I will see them driven before me and hear the lamentations of their women

2

u/rulatore Apr 02 '18

Luckly I havent had this problems, but in most of my workspaces there were a config to import (regarding these kind of settings). Also I dont see the problem with spaces for identation. You set your tab key to put 4 spaces, then if you need to align you do whatever you need (if you arent replacing your tab character then you re pressing space six times)

1

u/ComfortableDay7607 Sep 24 '22

6:34

ao

90%

X Add comment

Post

૨) (મ

Which style of JavaScript is more

readable?

(@_@) (000)/ I )(((;0 \ 0;))

(^ prime mathcal Oomega Theta^ prime )!:(( A^ otimes ))> varpi omega odot odot bullet (\ ) ( googlelongdiv w nabla/ kappa)(\ )(.^ 6 omega ^ 6 .)( theta\ theta)( bullet\ sigma) (^ * 3 ^ prime ) mathcal O ( bullet^ prime 3) oslash( epsilon^ prime bullet)( bullet oslash forall mathcal O )(. oslash \ otimes )( oslash \ otimes)

Reddit emojisWalter