作用域,变量提升(待更新)

>  首先看一道我网上看到的面试题

1  var number = 1;
2     function info(){
3         number = 2;
4         console.log(number);
5         //有函数,number不变;没函数,number变2
6         function number(){};
7     }
8     info();//输出2
9     console.log(number);//输出1

> 解决这道题面,我们先要搞清楚几个知识点
1.作用域

 



猜你喜欢

转载自www.cnblogs.com/-constructor/p/10625568.html