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 OverflowWhen should you use "var", "let", or "const" in JavaScript code - Stack Overflow
Difference between var, let and const
[SOLVED] What is the difference between let, const and var? - Help & Support - PlayCanvas Discussion
Understanding var/let and const
Videos
Hi 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!)
Can you all help me understand these? Unless specified can I name them as I want? Or I guess explain them to me please, I’m 49 years old and working on JavaScript tyia