Which is better, var or let? (JavaScript)

var for the win! I don’t care if it’s outdated or messes up in the global scope; it wOOORKS!

1 Like

Wait please don’t tell me you actually use var in JavaScript…


I do all the time. And before you lecture me on how let is better, I don’t care.


Well you see, let is easier to type.

There, that’s the end of my lecture.

1 Like

21 posts were split to a new topic: What fingures do you use to type?

I was just writing some JS, and I wrote var, but just for you guys I changed them to let.

The only reason I use var is because it has an actual meaning

well, I did use var for a long time until I found scopes. Ever since, I’ve limited myself to let, const, and window.variableName, only using var in stuff I don’t care about. Using let/const helps me reduce the probability that I redefine an active variable as something else, causing an error in some other section of code.


I’m kinda weird because I use all three.

  • const for node (like port numbers) and also for variables that will stay the same throughout the program.

  • var for variables that will change value in the program

  • let for scopes and stuff (mainly global)

But I’m glad about one thing, at least JavaScript does use these keywords for variables, whereas Python doesn’t and it can get quite confusing if you have complicated code.

And in terms of typing ease, let can be faster but uses 2 hands. However var is slightly slower for me but it only uses 1 hand.


So does let, though. let also forms a sentence so it’s easier to read. You let a variable be a value. Simple as that.


I think it’s like that in regular math too, like “let x be 4”