Why do some back-end code use ‘var’ instead of ‘const/let’?

Why do some back-end code use ‘var’ instead of ‘const/let’?
0

#1

No specific examples (besides I guess FCC’s back end challenges). I noticed from reading some docs, or open source code that while const and let are used, there’s the occasional ‘var’ declarations (typically in callbacks).

I might’ve missed an explanation about this when learning. What would be the main reasons someone would do this?


#2

An answer for the diff between using var and let.

As for const, I think if it’s you want it to be rigid, and less prone to changes. As soon as you assign a value to const, it cannot be changed (mostly).


#3

The main reason is probably legacy code from before let and const were codified and widely supported

Updating code takes time that is often spent on new features or priority bugs


#4

And @gebulmer is 100% right, but if you want the real case uses, I placed a few links to help you on that front.