js中字符串操作函数

1.concat()  //拼接字符串,不改变原字符串

2.charAt() //返回字符串中指定未知的字符

3.substr() //substr(0,1)  返回从下标为0的字符开始长度为2 的字符串

4.substring() //str.substring(1,4)  返回从1到4的子串

5.splice()  //提取字符串中的一部分并返回一个新的字符串,通substring()

6.split()   //将字符串分成字符串数组

str='hello world welcome';
str.split("")        //[h,e,l,l,o, ,w,o,r,l,d, ,w,e,l,c,o,m,e]
str.aplit(" ") //[hello,world,welcome]
str.split(" ", 2) //[hello,world] 第二个参数2代表字符串数组的最大长度

7.length   //字符串长度

8.toLowerCase()  //转化为小写

9.toUpperCase()  //转化为大写

原文地址:https://www.cnblogs.com/150536FBB/p/11345502.html