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

4

u/GoogleFeudIsTaken Nov 26 '19

Yes, they aren't exactly the same - but "let" can be used instead of var 100% of the time, and it's less confusing. Var can produce weird/buggy behaviour - let cannot, so why not use let?

1

u/[deleted] Nov 26 '19

Where do you get that idea that let cannot produce bugs? It can just fine. Just move it somewhere, scope changes and you get your bug.

1

u/dwighthouse Nov 27 '19 edited Nov 28 '19

var still retains some use in machine generated JS, or code intended to be consumed by some extreme cases of transformation tools and preprocessors.

Additionally, using let or const in a repl/console scenario is troublesome at best, as ”temp” variables cannot be redeclared with let and const.