(011)javascript语法基础

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5     <title>妙味课堂</title>
 6     <script type="text/javascript">
 7 
 8         var a = 5;
 9 
10         //alert(typeof a); //number类型
11 
12         a = 'abc';
13 
14         //alert(typeof a); //string类型
15 
16         a = true; 
17 
18         //alert(typeof a); //boolean类型
19 
20         a = function() {
21             alert("function"); 
22         };
23 
24         //alert(typeof a); //function类型
25 
26         /* 
27            undifine (1)变量未定义 (2)变量定义了未存放数据
28          */
29         var b;
30 
31         //alert(typeof b);//undefined类型(b中未存放数据,无法确定类型)
32 
33         window.onload = function() {
34 
35             var div = document.getElementById("div1");
36             //alert(typeof div);
37             alert(typeof document);
38         }
39         
40     </script>
41 </head>
42 
43 <body>
44     <div id="div1"></div>
45 </body>
46 </html>

 

posted @ 2014-01-21 23:35  雪中飞雁  阅读(93)  评论(0)    收藏  举报