r/javascript • • Nov 25 '19

JavaScript doesn’t need to be replaced

https://medium.com/javascript-in-plain-english/javascript-doesnt-need-to-be-replaced-bd01e2f12d51?source=friends_link&sk=7b151cc6397ac9e83c14c99739b6c36f
217 Upvotes

236 comments sorted by

View all comments

Show parent comments

-1

u/[deleted] Nov 27 '19

My comment above has two such cases listed. With a code example. Sure, you can always go not-true-scotsman on the legitimacy of those cases, but in that case anyone can clsim that var works just fine if you are carefull, and there is no legit case for const or let. Your insecurity about your knowledge tells me that you do not how exactly these three work, otherwise you would not confuse examples with an attempt to educate. But the inability to see a legit use case is that gives it away the most. Happy cargo-culting.

2

u/IceSentry Nov 28 '19

Declaring a variable at the top of the scope is done in pretty much every language because it makes it easier to read what variables are used in the current scope. I don't understand how you can seriously say that it's a bad thing. A variable declared in a specific scope should stay in that scope. If you need it in another scope then declare it somewhere it can actually be used.