# String
String 对象可以用来表示和操作一个字符串。
# 静态方法
String.fromCharCode()
:通过 unicode 字符创建字符串String.fromCodePoint()
:通过一串码点创建字符串String.raw()
:通过模板字符串创建字符串
# 实例属性
length
:长度
# 实例方法
charAt(index)
:指定位置的字符charCodeAt(index)
:指定位置字符的 unicodecodePointAt(index)
:返回使用 UTF-16 编码的给定位置的值的非负整数concat(str[, ...strs])
:连接字符串includs(searchStr[, fromIndex])
:从 index 位置开始检索,返回是否能检索到 searchStrendsWith(searchStr[, length])
:是否以 searchStr 结尾,length 为被检索字端的长度indexOf(searchStr[, fromIndex])
:从 fromIndex 位置开始开始向右检索 searchStr,没有检索到返回 -1,检索到返回首次出现的位置lastIndexOf(searchStr[, fromIndex])
:从 fromIndex 位置开始向左检索 searchStr,没有检索到返回 -1,检索到返回首次出现的位置localCompare(compareStr[, locales[, options]])
:比较两个字符串,如果引用字符串在比较字符串前面,返回负数,相等返回 0,否则返回正数match(regexp)
:使用正则表达式匹配字符串matchAll(regexp)
:使用正则表达式匹配字符串normalize([form])
:按照指定的一种 Unicode 正规形式将当前字符串正规化padEnd(targetLength[, padStr])
:使用 padStr(缺省为''
)循环填充原字符串尾部,直到 targetLength 长度为止,如果 targetLength 小于原字符串长度,则返回原字符串padStart(targetLength[, padStr])
:使用 padStr(缺省为''
)循环填充原字符串头部,直到 targetLength 长度为止,如果 targetLength 小于原字符串长度,则返回原字符串repeat(count)
:重复字符串,count 范围为 [0, +∞)replace(searchFor, replaceWith)
:替换字符串replaceAll(searchFor, replaceWith)
:替换字符串search(regexp)
:对正则表达式和指定字符串进行匹配搜索,返回第一个出现的匹配项的下标slice(beginIndex[, endIndex])
:截取字符串,参数可为负数split(sep[, limit])
:使用 sep 分隔符将字符串分割成数组,limit 为数组的长度startWith(searchStr[, index])
:判断引用字符串是否以搜索字符串开头,从 index 处开始计算substring(indexStart[, indexEnd])
:截取字符串,小于 0 的参数当作 0 处理toLocalLowerCase([locale, ...locales])
:返回字符串的小写形式toLocalUpperCase([locale, ...locales])
:返回字符串的大写形式toLowerCase()
:返回字符串的小写形式toString()
:重写Object.prototype.toString()
toUpperCase()
:返回字符串的大写形式trim()
:去掉首尾空字符trimStart()
:去掉首部空字符trimEnd()
:去掉尾部空字符valueOf()
:重写Object.prototype.valueOf()
[Symbole.iterator]()
:迭代器访问字符的方法