1、长度
str.length;
2、从指定位置开始检索指定文本首次出现的索引位置
let index = str.indexOf(str2,2);
3、从开头到指定索引位置检索指定文本最后一次出现的索引位置
let index = str.lastIndexOf(str2,4);
4、搜索指定文本的位置
let index = str.search();
5、字符串截取
截取从起始索引到终止索引的字符串,源字符串不变
let str2 = str.slice(index1,index2);
substring();与slice其它相同,不接受负数
substr();第一个参数为起始索引,第二个为长度不接受负数
6、转换大写
toUpperCase();
7、删除字符串两端空白字符,原数组不改变
str.trim();
8、字符串合并,产生新数组,原来两个数组不变
let str3 = str2.contact(str1);
9、查找指定下标的字符
str.charAt(index);
10、字符串分割为数组
let arr = str.split();
11、文本替换,第一个参数为要被替换的文本,第二个为要替换的文本
str.splice(str2,str3);