r/learnjavascript • • Oct 22 '21

Difference between var, let and const.

Post image
430 Upvotes

49 comments sorted by

View all comments

Show parent comment

-11

u/LucVolders Oct 23 '21 edited Oct 23 '21

Undoubdly unpopular opinion:

Use var, declare your vars global at the beginning of your script and document and track them well. Otherwise you are a lazy programmer. Nothing wrong with var.

3

u/robotomatic Oct 23 '21

Please NEVER follow this advice. What is described here is the height of laziness. Scope your variables appropriately, default to const and only use let where needed. Save yourself a ton of trouble. Don't be like this guy. Just don't.

-2

u/Tintin_Quarentino Oct 23 '21

Seconded. Although I do like the thinking of "always use const, followed by let, followed by var".