In this article you learn what is difference between var, let, const. You will learn what are they and how to used them.
var name = "John"; console.log(name); name = "Jane"; console.log(name);
let is new var. We use it to store variable values. Use let to declare variables if that variable value will be changed.
let name = "John"; console.log(name); name = "Jane"; console.log(name);
Use const if variable value is constant and it will not be changed. const variable values cannot be changed.
const name = “John”;
name = “Jane”;
You will get the following error as const cannot be changed. So, use const only when you know that value is not going to change.
If you have any question about this topic, you can ask me through the comment section.