javascript 基礎2第12節

來源:互聯網
上載者:User

標籤:

1.

<html><head><title>javascript基礎</title></head><body>1.Number</br><script type="text/javascript"> var  ia  = 10;//基本類型  typeof var  name = ‘張三‘; var  married = false; var oNum = new Number(10); var oName = new String(‘張三‘); document.write("typeof ia :  " ,typeof ia,"<br/>");  document.write("typeof name :  " ,typeof name,"<br/>");  document.write("name.toString() :  " , name.toString(),"<br/>");//偽對象  document.write("typeof oName :  " ,typeof oName,"<br/>"); document.write("typeof oNum :  " ,typeof oNum,"<br/>");//物件類型檢測  instanceof document.write("oNum instanceof Number :  " , oNum instanceof Number,"<br/>"); document.write("ia == oNum :  " ,ia == oNum,"<br/>"); document.write("ia === oNum :  " ,ia === oNum,"<br/>"); var  ob = Number(‘123‘);//基本類型 document.write("typeof ob :  " ,typeof ob,"<br/>"); document.write("ob :  " , ob,"<br/>");  document.write("Number.MAX_VALUE :  " , Number.MAX_VALUE,"<br/>");document.write("Number.MIN_VALUE :  " , Number.MIN_VALUE,"<br/>");var ib = 3.148592654233789;  //new Number();document.write("ib :  " , ib,"<br/>");document.write("ib.toFixed(2) :  " , ib.toFixed(2),"<br/>");</script>     2.Boolean</br><script type="text/javascript">document.write("Boolean(5) :  " , Boolean(5),"<br/>");document.write("Boolean(null) :  " , Boolean(null),"<br/>");document.write("Boolean(‘a‘) :  " , Boolean(‘a‘),"<br/>");</script>     3.String</br><script type="text/javascript">var  str = "Hello World Hello JavaScript  I like jaVAScript you like JAVAscript"; document.write("str :  " , str,"<br/>");document.write("str屬性length :  " , str.length,"<br/>");document.write("str.toUpperCase() :  " , str.toUpperCase(),"<br/>");document.write("str.toLowerCase() :  " , str.toLowerCase(),"<br/>");document.write("str.charAt(0) :  " , str.charAt(0),"<br/>");document.write("str.charAt(X) :  " , str.charAt(str.length-1),"<br/>");document.write("str.charCodeAt(19) :  " , str.charCodeAt(19),"<br/>");document.write("str.concat(10,‘abcd‘,true) :  " , str.concat(10,‘abcd‘,true),"<br/>");document.write("String.fromCharCode(97) :  " , String.fromCharCode(97),"<br/>");//尋找document.write("str.indexof(‘java‘) :  " , str.indexOf(‘java‘),"<br/>");document.write("str.indexof(‘java‘) :  " , str.toLowerCase().indexOf(‘java‘),"<br/>");document.write("str.indexof(‘java‘,20) :  " , str.toLowerCase().indexOf(‘java‘, 20),"<br/>");document.write("str.lastIndexof(‘java‘) :  " , str.toLowerCase().lastIndexOf(‘java‘),"<br/>");//截取document.write("str.slice(6,11) :  " , str.slice(6,11),"<br/>");document.write("str.substr(6,5) :  " , str.substr(6,5),"<br/>");document.write("str.substring(6) :  " , str.substring(6),"<br/>");var data = "2014-7-28";var arr = data.split(‘-‘);//字串數組document.write("arr[0] :  " , arr[0],"<br/>");document.write("arr[1] :  " , arr[1],"<br/>");document.write("arr[2] :  " , arr[2],"<br/>");</script>     </body></html>

 2.結果:

3.

javascript 基礎2第12節

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.