1 <script type="text/javascript"> 2 cosole.log(eve); //undefined 3 </script> 4 <script type="text/javascript"> 5 function eve(){ 6 console.log("eve"); 7 } 8 </script>
1 <script> 2 alert(typeof eve); //function 3 function eve() { 4 alert('I am Laruence'); 5 }; 6 </script>
- 在JS中, 是有预编译的过程的, JS在执行每一段JS代码之前, 都会首先处理var关键字和function定义式;
- JS的预编译是以段为处理单元的;
参考:http://www.laruence.com/2009/05/28/863.html