Why the last output is "3a: 1" (strict is false)?

Viewed 51

var a;
console.log('1 a: ' + a);
if (true) {
    a = 1;
    function a() { };
    a = 5;
    console.log('2 a: ' + a);
}
console.log('3 a: ' + a);

The output is:

1 a: undefined
2 a: 5
3 a: 1

I can't understand the last output "3 a: 1". Why not "3 a: 5" ?

0 Answers
Related