By reading this post, you will stop searching about this topic on google. So let's get started.
var x = 10; console.log(x); // will return 10 var x = 20; console.log(x); // will return 20 x = 30; console.log(x); // will return 30
let x = 10; console.log(x); // will return 10 let x = 20; console.log(x); // will show an error like x is already been declared. x = 20; console.log(x); // will return 20
So that's how you can change/ replace the value of x by just not including the keyword let. But if you include it, it will show an error.
The variable declared with 'const' is unchangeable. You can't replace or change the value of a constant variable. If you try to do that, it will show an error. Like " has already been declared.
const x = 10; console.log(x); // will return 10 x = 10; console.log(x); // will show an error const x = 20; console.log(x); // will show an error
So that was the difference between 'var', 'let' and 'const'. So which one should you use? I recommend you to use 'let'. It will be much effective than using 'var'.