js-String
1.一個字符串可以使用單引號或雙引號
2.查找
字符串使用 indexOf() 來定位字符串中某一個指定的字符首次出現的位置
如果沒找到對應的字符函數返回-1
lastIndexOf() 方法在字符串末尾開始查找字符串出現的位置。
3.length長度
4.內容匹配
match()函數用來查找字符串中特定的字符,并且如果找到的話,則返回這個字符。
5.替換內容
replace("","")?方法在字符串中用某些字符替換另一些字符。
6.字符串大小寫轉換
字符串大小寫轉換使用函數?toUpperCase()?/?toLowerCase()
7.字符串轉為數組
字符串使用split()函數轉為數組:
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()
轉載于:https://www.cnblogs.com/huoran1120/p/5977977.html
總結
- 上一篇: android 原色调渲染
- 下一篇: 多线程的本质