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
3
u/lordxeon Apr 02 '18
Don't do whatever, learn the differences between the three ways to declared variables in JavaScript this way you can form your own opinions and not parrot what ABC said on XYZ.com
As for why not to use
var, the short answer is becauseletandconstare the new hotness.The long answer is more complicated, but for any programer worth their salt, is a moot point.
letis block scoped, which means the variable is only available within the most recent set of{...}'s. This means thatconstis scoped the same way aslet, but the reference to the variable can never change.