淺談javascript中字串String與數組Array,stringarray

來源:互聯網
上載者:User

淺談javascript中字串String與數組Array,stringarray

簡單點就是string是字元(串)...
而array是數組...可以放數字啊,字元啊等一系列東東!!!

上個樣本:

複製代碼 代碼如下:
var str = "liuzhanqi";
document.write(str["length"]);//等價str.l ength 
var str = string.fromcharcode(72, 101, 108, 108, 111, 33);
document.write(str); //各整數作為unicode編碼,並串連成字串。
var str1 = "liu".localecompare("zhan");//按本系統提供的預設比較規則比較當前字串與參數字串
document.write(str1);//
var str2 = "liu".slice(1);//在當前字串中提取一個子字串
document.writeln(str2);
document.writeln("se nki".split(' '));//用分隔字元分割字串,返回一個數組。
document.write('liu'.fontcolor('red'));
document.write('liu'.fixed());//使字串顯示為等寬字
document.write('liu'.strike());//在字串上添加刪除線
document.write("senki".sub());//顯示為下標
document.write("senki".sup());//顯示為上標

charCodeAt(index)  返回字串index處的字元的Unicode編碼,該值是在0~65535之間的整數,若index超出了範圍,則返回NaN。

concat(str2)  將字串str2串連在當前字串組成一個新的字串。

anchor(anchar_name)  建立一個錨點

link(url)  加上超連結

charAt(index)  返回字串中index指定位置處的一個字元

小夥伴們是否瞭解了javascript中字串String與數組Arry了呢,有疑問請給我留言吧,大家共同進步。

聯繫我們

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