JS(二)數字對象和字串對象

來源:互聯網
上載者:User

標籤:javascript   對象   

一、js功能

因為學的東西比較多,容易混淆。也不可能一個個的記住,這裡備忘一下,以後要用到的時候,就能快速的回想起來。

index-number.js

/** * 顯示數字對象 */function myFunction() {var x1 = 3.14;// 小數var x2 = 11;// 整數var x3 = 14e5;// 大數字var x4 = 0237;// 八進位var x5 = 0x12f;// 十六進位var y = 0.1 + 0.2;var str = "x1:" + x1 + "<br/>x2:" + x2 + "<br/>x3:" + x3 + "<br/>x4:" + x4+ "<br/>x5:" + x5;document.write(str + "<br/>");document.write(y);}/** * 顯示字串對象 */function myFunction2(){var str="<p>這個是js對象的文字內容</p>";var str2="Black";var str3="這個是js對象的文字內容"document.write(str.italics());//文字為斜體document.write(str.fontcolor("#ff0000"));//文字顏色為紅色,注意大小寫document.write(str.link("http://www.baidu.com"));//點擊內容跳轉的連結document.write(str.bold());//文字為粗體document.write(str2.toLocaleLowerCase());//小寫document.write(str2.toUpperCase());//大寫document.write(str.fontcolor("red").fontsize(20));//同時改變文字顏色和字型大小document.write(str3.fontsize(20) + str2.sub()+str3.fontsize(20)+str2.sup());//上標和下標document.write(str.replace("js","JavaScript"));//替換}


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.