js 变量作用域
?
例子
<script>var a = "heh"function findLove(){console.log(a);function findforyou(){var a ="you";console.log(a);}function findother(){console.log(a)}findforyou();findother();}findLove(); </script>輸出
heh you heh?
例子
<script>var test_id = "my love";if(true){console.log(test_id);var test_id = "where my love?";console.log(test_id);}console.log(test_id); </script>輸出
my love where my love? where my love??
例子
<script>var test_id = "my love";function findLove(){var test_id ;console.log(test_id);test_id = "is you?";console.log(test_id);}findLove();console.log(test_id); </script>輸出
undefined is you? my love?
例子
<script>var a = "heh"if(true){console.log(a);} </script>輸出
heh?
例子
<script>var a = "heh"function findLove(){console.log(a);}findLove(); </script>輸出
heh?
例子
<script>var a = "heh"function findLove(){console.log(a);var a}findLove(); </script>輸出
undefined?
轉(zhuǎn)載于:https://www.cnblogs.com/sea-stream/p/10755335.html
總結(jié)
- 上一篇: 转载 Net多线程编程—System.T
- 下一篇: Java相关资料分享(视频+电子书籍)