r/learnjavascript • • Oct 22 '21

Difference between var, let and const.

Post image
430 Upvotes

49 comments sorted by

View all comments

30

u/zerik100 Oct 22 '21

tldr; never use var and if you think your code requires var then there's something wrong with your code

-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.

-2

u/Tintin_Quarentino Oct 23 '21

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