变量定义了 但是没有赋值的情况下 也会是undifine var n; alert(typeof(n))

 1 <!DOCTYPE HTML>
 2 <html>
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 5 <title>无标题文档</title>
 6 </head>
 7 
 8 <body>
 9     <script>
10         //真 假
11         var n;
12         alert(typeof(n))
13         if(n){
14             alert('真的')    
15         }else{
16             alert('假的')
17         }
18     </script>
19 </body>
20 </html>

 

posted on 2015-07-29 15:42  zhangjingyun  阅读(358)  评论(0编辑  收藏  举报