js中var的变量和function的函数名重名时的执行结果
如果var的变量和function的函数名重名时,var的优先级更高,先执行var,按照var划分区域,但是遇到function,function会直接占用,也就是说最终执行function
console.log(a); //f a(){}
var a=10;
function a(){
};
console.log(a); //10
执行过程如下:
var a;
function a(){
};
console.log(a); //f a(){}
a=10;
console.log(a); //10