In my opinion nowadays it is better to use let and const.
According to the ES6 standard, these options are more convenient with their scope. Both give us the so-called block scope. This means that the scope of their use can be limited to a block of code, such as a for loop or an if expression. This gives the developer more flexibility in choosing the scopes of variables.
In addition, if we consider these options, then you will not be able to change the variable declared with const, unlike var and let.
Generally speaking, let and const are often used now, depending on the need.
Answer from nixanosize on Stack OverflowHi everyone!
I'm pretty new to web development and have started to read a little bit about javascript. Right now I'm trying to learn how to declare a function but realized that there is different ways to do this using var, let or const. Since I'm new to this, most of the explanation on the internet is pretty advanced to understand atm, so could anyone explain the differences for me very short short and easy, alternatively give me a link that explain it in pretty easy terms?
Thanks in advance!
(Edit: Thank you so much for the answers, rly appreciate it!)
Videos
Being able to briefly explain stuff is a real skill. Let's train it!
How would you explain it in the simplest way in 25 words?