string物件的相關函式:
replace(str1,str2):將字串的str1換成str2
split(,):將字串轉換成陣列
length:計算字串的長度
indexof(str1,n):計算字串中第n次出現str1的位置
lastindexof():從右向左數查詢字串的位子
match(str):字串匹配,如果目標字串中存在str,則返回str,如果目標字串中沒有str,則返回-1
touppercase():將字串轉換成大寫的
tolowercase():將字串轉換成小寫的
charat():返回字串中第n 個字元
JS中String物件的常用方法
1 charcodeat方法返回乙個整數,代表指定位置字元的unicode編碼。strobj.charcodeat index 說明 index將被處理字元的從零開始計數的編號。有效值為0到字串長度減1的數字。如果指定位置沒有字元,將返回nan。例如 var str abc str.charcode...
擴充套件js的String物件
有些時候我們需要對字串做一些原生js不支援的複雜操作,可以考慮擴充套件string物件 string.prototype.delhtmltag function var str likai console.log str.delhtmltag 我們知道在使用js開發的時候,遇到很多的程式 都要自己寫...
js的String物件方法
1 tolowercase 把字串轉為小寫,返回新的字串。var str hello world var str1 str.tolowercase console.log str hello world console.log str1 hello world2 touppercase 把字串轉為大...