Read this example is estimated that you will understand
var a = 'global'; function test() { if (!a) { var a = 'part'; } console.log(a); } test()
As a result part, because there are variables declared in advance.
function test() { var a; if (!a) { a = 'part'; } console.log(a); }
When this function is called, will now enhance this function in the initialization of variables.
Therefore, in normal operation, we should minimize the use of var, and let multi const.