设为首页 加入收藏

TOP

JS 函数作用域及变量提升那些事!(二)
2017-10-16 18:19:19 】 浏览:2220
Tags:函数 作用 变量 提升 那些
//1

 

又是华丽丽的分割线———————————————————————————————————————————

以下另外一些思考题,可以自行理解喔 ^_^

 1 var foo = 0;
 2 (function fn1(){
 3     foo = 1;
 4     console.log(foo);//1
 5     (function fn2(){
 6         var foo = 2;
 7         console.log(foo);//2
 8         (function fn3(){
 9             foo = 3;
10             console.log(foo);//3
11         }());
12     }());
13 }());
14 console.log(foo);//1

 

1 (function fn1(){
2     (function fn2(){
3         (function fn3(){
4             foo = 3;
5         }());
6     }());
7 }());
8 console.log(foo);//3

 

1 (function fn1(){
2     (function fn2(){
3         var foo;
4         (function fn3(){
5             foo = 3;
6         }());
7     }());
8 }());
9 console.log(foo);//Uncaught ReferenceError: foo is not defined

 

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇echarts饼图扇区添加点击事件 下一篇弹性盒模型----容器属性

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目