关于JS的作用域

出一道题目,这道题要是会了基本上也就知道了。

JS作用域题目:

 var x = 1; //全局变量

 function ScopeTest(){

    alert( x );    

     var x = 'hello world';

    alert( x );    

 }

 ScopeTest();

 


来源:http://www.cnblogs.com/rainman/archive/2009/04/28/1445687.html 

posted @ 2010-06-21 20:47  梅子  阅读(600)  评论(6编辑  收藏  举报