concat方法
const方法是连接多个字符串,并返回连接后的副本
var a="hello";
var b="world";
a.concat(b);//helloworld;
indexOf方法与lastIndexOf
返回在父字符串中第一次出现的位置,若没有则返回-1,而lastIndexOf则是返回最后一次出现的位置,没有则返回-1;
var a="1,2,3,4,5";
a.indexOf('5');//8;
a.lastIndexOf('5');//8
replace方法
replace(start,value)方法是替换,start是你要替换掉的值(可以使用正则表达式),value是你要替换成的值;
var a="helloWorld";
a.replace(/l/g,"L");//heLLoWorLd;
a.replace('h',"H");//HelloWorld;
slice(start,end)方法
start为开始下标,end为结束下标(不包含该下标);返回start与end之间的字符串
var a="hellowrld";
a.slice(2,4);//ll
substr(start,length)
从字符索引start的位置开始返回长度为length的字符串
var a="helloworld";
a.substr(0,3);//hel