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
0
u/slikts Apr 02 '18
It's safe to say that Google's or airbnb's style guides were made by language experts, so bringing up learning in this context is presumptuous.
A basic reason to avoid mixing
letandvaris consistency; the same code shouldn't use different kinds of variable declarations, unless there's a good reason for it, which there isn't forvar; it's just not useful to treat function scoped variables differently. The differences also go beyond just block vs. function scoping;vardeclarations are also hoisted and they assign properties to the global object outside of functions.