JS總結二....

來源:互聯網
上載者:User

標籤:

1.布爾類型:只有兩種值,true和false,與字串不同,不用用引號括起來。ongoing面向

2.物件類型:javascript是物件導向語言,對象就是由一些彼此相關的屬性和方法集合在一起而構成的一個資料實體。

3.Array數群組類型:數組也是存放資料的一種容器,只不過它能存放多個資料。數組的索引預設是0開始的。

4.Null:表示什麼都沒有。null是一個只有一個值的特殊類型。表示一個Null 物件引用。

5.undefined:表示一個沒有設定值的變數。typeof 一個沒有值的變數會返回undefined。

Null和undefined的區別:typeof undefine-->undefine

            typeof null-->object

            null === undefine  //false

            null == undefine //true

6.資料類型的查看和轉換:

a.查看資料類型typeof ,var mood = "happy";alert(typeof mood);alert(typeof 95);

b.轉換成字串類型:var age = 25;alert(age.toString());

c.轉換成數字:parseInt() 轉換成整數;parseFloat()轉換成浮點數。var text = parseInt("blue")-->return NaN  var test = parsetInt("1234blue")-->return1234  var test = parset("22.5")-->return 22  var test = parsetFloat("1234blue")-->return1234  var test = parseFloat("22.5")-->return22.5

7.判斷變數類型:var a = "cc" typeof a =>"string";

        var a = 22 typeof a =>"number";

        如果a 是一個數實值型別,但內容不是一個有效數字,會顯示NaN。

        typeof NaN =>NaN

        var a; typeof a =>undefine

8.運算子:

1.算術運算子(+、-、*、/、%)值得注意的是+號,除了可以表示加法運算外,當兩個相加的變數不都是數字類型的時候,會起到拼接的作用。alert("10" + 10) =>1010;

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.