js-String
1.一個字符串可以使用單引號或雙引號
2.查找
字符串使用 indexOf() 來定位字符串中某一個指定的字符首次出現(xiàn)的位置
如果沒找到對應(yīng)的字符函數(shù)返回-1
lastIndexOf() 方法在字符串末尾開始查找字符串出現(xiàn)的位置。
3.length長度
4.內(nèi)容匹配
match()函數(shù)用來查找字符串中特定的字符,并且如果找到的話,則返回這個字符。
5.替換內(nèi)容
replace("","")?方法在字符串中用某些字符替換另一些字符。
6.字符串大小寫轉(zhuǎn)換
字符串大小寫轉(zhuǎn)換使用函數(shù)?toUpperCase()?/?toLowerCase()
7.字符串轉(zhuǎn)為數(shù)組
字符串使用split()函數(shù)轉(zhuǎn)為數(shù)組:
txt="a,b,c,d,e"?? // String
txt.split(",");?? // 使用逗號分隔
8.常用字符串屬性和方法
屬性:
- length
- prototype
- constructor
方法:
- charAt()
- charCodeAt()
- concat()
- fromCharCode()
- indexOf()
- lastIndexOf()
- match()
- replace()
- search()
- slice()
- split()
- substr()
- substring()
- toLowerCase()
- toUpperCase()
- valueOf()
轉(zhuǎn)載于:https://www.cnblogs.com/huoran1120/p/5977977.html
總結(jié)
- 上一篇: android 原色调渲染
- 下一篇: 多线程的本质