'I want to know about the pre-compiled enhancement of block level scope in JavaScript

I want to know why the line a=21 does not change the global scope of A, but recreates a in the block scope

var a;
if(true) {
    function a(){}
    a = 21 // ?
    console.log(a);
}
console.log(a);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source