1.charAt() 返回在指定位置的字符,相当于数组的下标
2.concat() 连接字符串(和数组一样)
console.log("dfa".concat("郭丹丹"));
3.indexOf() 检索某个子字符串在整个字符串中的定位
console.log("dhsjadf".indexOf("adf"));
4.replace() 替换
console.log("abcdefgaa".replace("a","郭丹丹"))
5、slice() 提取(和数组一样)
console.log("我爱你亲爱的祖国的人民币".slice(-3,-1) );
6、split() 把字符串→数组, 从什么地方拆分, 就是参数
-
"我爱你亲爱的祖国的人民币".split("的");
|
拆开的是字符串:
-
1嘻嘻2嘻嘻3嘻嘻4嘻嘻5嘻嘻6".split("嘻嘻")
|
7.substr() 截取子串
“字符串”.substr(start,length)
-
"abcdefghijklmn".substr(3,5);
|
从下标为3的地方开始,取5个字符
8、substring() 截取子串
“字符串”.substring(start,end); 不包括end
-
"abcdefghijklmn".substring(3,5);
|
substr和substring不一样:
-
"我爱你亲爱的祖国的人民币".substr(6,2)
|
-
"我爱你亲爱的祖国的人民币".substring(6,8)
|