Having the following for-loop:
for (var i = 0; i < 3; ++i) {
    console.log(i, p);
    var p;
    p = 42;
}
I was expecting the output to be:
0 undefined
0 undefined
0 undefined
But actually, the output is:
0 undefined
0 42
0 42
Since we're using var p (to redeclare p) next line, why isn't p undefined (always) in the console.log line?
 
    