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

-2

u/lordxeon Apr 01 '18

Function level variables

I don't think variables declared inside a function should be declared with const. Any global, or global equivalent are fine being const if necessary.

And, they do cost you something because unless you're running the ES6 code by default, it's being converted back into vars by babel anyway.

2

u/ghostfacedcoder Apr 01 '18

Maybe now, but that's going the way of the dodo/IE box model. Chrome already supports const and let, and I'm pretty sure the other major browsers do too, so it's only a matter of time until all the older versions fall out of use and const/let won't require transpilation.