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

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?

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

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

1 Like

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