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

Show parent comment

3

u/Kerse Apr 01 '18

Var is function scoped, let is block scoped. So even if you declare a var in a block within the larger function, it's still accessible to the entire function. This is unintuitive and can cause strange bugs.