DEV Community

Discussion on: Variables in JavaScript

Collapse
mshajid profile image
mshajid

Sorry No offense, Am I the only who using let & const in 2020? Why still using "var"? To be honest, I'm also a newbie although, just let me know what is the core differences between them using in 2020?

Collapse
sashankr profile image
Sashank Rampalli Author

Yes let and const are part of es5 and they are used in modern JS code, however, there is still a lot of old code written with var.

I am sharing the basics of variables from Vanilla JS.
Well, const is mainly used to prevent reassigning and overriding its value.
let is used mostly in loops because the counter value has to be reassigned every time.