js學習記錄

來源:互聯網
上載者:User

標籤:null   object   對象   cto   float   rip   記錄   script   eof   

js  資料類型

typeof "John"                 // 返回 string
typeof 3.14                   // 返回 number
typeof NaN                    // 返回 number                 isNaN(),判斷是否為非數值
typeof false                  // 返回 boolean
typeof [1,2,3,4]              // 返回 object                    數組比較特殊,返回object類型
typeof {name:‘John‘, age:34} // 返回 object
typeof new Date()             // 返回 object
typeof function () {}         // 返回 function
typeof myCar                  // 返回 undefined (如果 myCar 沒有聲明)
typeof null                   // 返回 object              undefined                      //undefined
  constructor 屬性返回所有 JavaScript 變數的建構函式。你可以使用 constructor 屬性來查看對象是否為數組 (包含字串 "Array"):   "John".constructor                 // 返回函數 String()  { [native code] }
(3.14).constructor                 // 返回函數 Number()  { [native code] }
false.constructor                 // 返回函數 Boolean() { [native code] }
[1,2,3,4].constructor             // 返回函數 Array()   { [native code] }
{name:‘John‘, age:34}.constructor // 返回函數 Object()  { [native code] }
new Date().constructor            // 返回函數 Date()    { [native code] }
function () {}.constructor        // 返回函數 Function(){ [native code] }     類型轉換,數群組轉換為數字。Number("3.14")    // 返回 3.14
Number(" ")       // 返回 0
Number("")        // 返回 0
Number("99 88")   // 返回 NaN 轉換為字串String(),    X.toString().字串轉換為整數,parseInt("A")          parseFloat()   

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.