js進階程式設計

來源:互聯網
上載者:User

標籤:程式設計   ons   進階   全域變數   事件   返回   erro   瀏覽器   console   

defer 非同步指令碼,指令碼延遲到文檔完全被解析和顯示之後再執行。只對外部指令檔有效。按順序執行指令碼。但在實際情況下,並不一定會按照順序執行
最好只有一個延遲指令碼。
支援H5的瀏覽器會忽略給指令碼設定 defer 屬性
async 非同步指令碼,不保證按指令碼的先後順序執行。
非同步指令碼一定會在頁面的Load事件前執行。

IE10+支援strict 模式

function test (){     a = 12;    //沒有var, a 是全域變數, 不推薦  strict 模式下會報錯 ”use strict" }test();console.log(a);  // 12var num = 12;  // 推薦加; if(a){   return true;   //  推薦加{}}

5種基礎資料型別 (Elementary Data Type) undefined null boolean number string
1種複雜資料類型 object          array function這兩個呢?

typeof   undefined  null 

console.log(typeof null);  // objectconsole.log(typeof 333);   // numberfunction abc () {  return 5;}console.log(typeof abc);  // function// undefinedvar a;   // 預設會有一個 undefined值 console.log(typeof a);  // undefinedconsole.log(typeof name);  // undefiend    不定義也是 Undefiendvar b = undefinedconsole.log(b === undefined);  // trueconsole.log(typeof undefined); // undefined// nullvar a = null;  // Null 物件指標console.log(typeof a); // object// 如果定義的變數b 準備用於儲存對象,那麼var b = null  感覺沒啥用var b = nullb = {"name": ‘kang123‘}if (b) {  // if(b!= null)  console.log(b.name);}console.log(null === undefined);  // false  類型不一致console.log(null == undefined);   //  true   undefined 值是派生null值的 ,ECMA-262 規定兩者相等
View Code

  返回false 

var a = NaNif(a){  console.log(‘ok‘);}else{  console.log(‘error‘);  // undefined null 0 false ‘‘ NaN }

 

js進階程式設計

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.