簡單點(diǎn)就是 string 是字符(串)...
而 array 是數(shù)組...可以放數(shù)字啊,字符啊等一系列東東!!! 上個(gè)示例:
[js] view plaincopy
var str = "liuzhanqi";
document.write(str["length"]);//等價(jià)str.l ength
var str = string.fromcharcode(72, 101, 108, 108, 111, 33);
document.write(str); //各整數(shù)作為unicode編碼,并連接成字符串。
var str1 = "liu".localecompare("zhan");//按本系統(tǒng)提供的默認(rèn)比較規(guī)則比較當(dāng)前字符串與參數(shù)字符串
document.write(str1);//
var str2 = "liu".slice(1);//在當(dāng)前字符串中提取一個(gè)子字符串
document.writeln(str2);
document.writeln("se nki".split(' '));//用分隔符分割字符串,返回一個(gè)數(shù)組。
document.write('liu'.fontcolor('red'));
document.write('liu'.fixed());//使字符串顯示為等寬字
document.write('liu'.strike());//在字符串上添加刪除線
document.write("senki".sub());//顯示為下標(biāo)
document.write("senki".sup());//顯示為上標(biāo)
charCodeAt(index) 返回字符串 index 處的字符的 Unicode 編碼,該值是在 0~65535 之間的整數(shù),若 index 超出了范圍,則返回 NaN。
concat(str2) 將字符串 str2 連接在當(dāng)前字符串組成一個(gè)新的字符串。
anchor(anchar_name) 創(chuàng)建一個(gè)錨點(diǎn)
link(url) 加上超鏈接
charAt(index) 返回字符串中 index 指定位置處的一個(gè)字符
小伙伴們是否了解了 javascript 中字符串 String 與數(shù)組 Arry 了呢,有疑問請(qǐng)給我留言吧,大家共同進(jìn)步。