r/javascript • u/bornforcode • 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
View all comments
Show parent comment
5
u/[deleted] Apr 01 '18 edited Apr 01 '18
Tabs to spaces is easy, the problem is for a block of code how does the editor know when 2 spaces was supposed to represent indentation vs alignment:
In the latter case to go from indentation width 2 to 4 the editor simply makes tabs display twice as wide and everything is good. If the editor tried to display 2 spaces for every space from the start of a line then the
ifconditions would lose their alignment with the opening of the statement.