1. 程式人生 > >妙味課堂視訊筆記總結

妙味課堂視訊筆記總結

1、Javascript組成:

    ECMAScript:直譯器、翻譯。幫助計算機讀懂人類寫出來的東西
    幾乎沒有相容性問題
    DOM:Document Object Model  把文件(網頁)變成JS可以操作的物件,給了JS操作頁面的能力——document
    有一些相容性問題
    BOM:Browser Object Model  給了JS操作瀏覽器的能力——window
    幾乎不相容

2、typeof

   typeof的常見型別:number string boolean object function undefined
   undefined出現的兩種情況:1、你真的沒有定義
                                                     2、雖然定義了但沒給值   
   eg:(1)  var a=12;
           alert(typeof a);                       //彈出一個number
      (2)  var a='abc';
           alert(typeof a);                      //string  
      (3)  var a=true;
           alert(typeof a);                     //boolean
      (4)  var a=function(){
              alert('abc');
            }        
            alert(typeof a);                   //function
      (5) <head>
               <script>
               window.onload=function()
               {
               a=document.getElementById('div1');
               }
               alert(typeof a);                //object   
               </script>
          </head>      
          <body>
          <div id="div1">dfwff</div>
          </body>
      (6)  var arr=[1,2,3,4];
           alert(typeof arr);                   //object
      (7)  var oDate=new Date();
           alert(typeof oDate);   //object      
      (8)  alert(typeof b);                  //undefined  沒有定義
      (9)  var b;
           alert(typeof b);                    //undefined 定義了沒有給值

3、物件object

    所有的物件都是複合型別,所有的複合型別都是物件。
    object是由:number string boolean undefined 組成的