In this tutorial there is written:
If you redeclare a JavaScript variable, it will not lose its value.
Why should I redeclare a variable? Is it
Keep in mind that only variables declared with var can be re-declared. If you try to re-declare a variable declared with let or const (which is the ES2015 Javascript syntax that should be used in most cases nowadays), even worse than losing the value, an error will be thrown:
let foo = 'foo';
let foo;
So, in codebases which use modern Javascript syntax, re-declaring a variable simply isn't possible - the interpreter needs to be able to identify a single point in the code after which a let or const variable gets properly initialized. Before that point, the variable name will exist in the temporal dead zone.