function test1(a = 1) {
console.log(a);
var a = 2;
function a() {}
}
function test2(a = 1) {
console.log(a);
function a() {}
}
test1(); // console log 1
test2(); // console log [Function: a]
According to the understanding of variable hoisting, the variable a in the first function has the same name as the function a, and finally the function a covers the variable a, and there is only the function a in the second function. The output result should be the same.So Why is the function default parameter valid in the test1 function but not in the test2 function?