//charAt返回字符串中下标元素
let str = "qwer12340abcd";
console.log(str.charAt(0));//q
//charCodeAt返回字符中下标元素的unicode编码。
let str1 = "qwer12340abcd"
console.log(str.charCodeAt(9));//97
//concat拼接字符串。返回拼接的字符串
let str2 = new String('qwer');
let str3 = str2.concat('12340abcd');
let str4 = '12340abcd'.concat(str2);
let str5 = '12340abcd'.concat(str2).concat(str2)
console.log(str3);//qwer12340abcd
console.log(str4);//12340abcdqwer
console.log(str5);//12340abcdqwerqwer
//endsWith判断字符串后面是否包含该元素。返回true||false
let a1 = "duan123@qq.com"
let a2 = a1.endsWith('@qq.com');
console.log(a2)//true
//startsWith判断字符串前面面是否包含该元素。返回true||false
let b1 = "duan123@qq.com"
let b2 = b1.startsWith ('duan');
console.log(b2)//true
//indexOf返回该元素在字符串中第一次出现的位置,若该元素在字符串中不存在则返回-1。否则返回该元素下标
let c1 = "312fhjdsf21"
let c2 = c1.indexOf('fh');
console.log(c2)//3
//lastIndexOf返回该元素在字符串中最后一次出现的位置。返回该元素下标
let d1 = "312fhjdsfh1"
let d2 = d1.lastIndexOf('fh');
console.log(d2)//8
//includes判断字符串中是否存在该元素。返回true||false
let e1 = "312fhjdsfh1"
let e2 = e1.includes('fh');
console.log(e2)//true
//split将字符串以-字符分隔成数组。返回数组,分隔也可以用其他的字符代替如(,)
let f1 = "166-4567-889"
let f2 = f1.split('-');
console.log(f2)//['166', '4567', '889']
//replace替换字符串中第一次出现的元素。返回字符串
let g1 = 'wertyuuiop'
let g2 = g1.replace('yu','aa');//将字符串中第一次出现的yu替换为aa
console.log(g2);//wertaauiop
//substr截取从下标开始的元素位置的长度的字符串。返回字符串
let h1 = 'wertyuuiop';
let h2 = h1.substr(0,3);//从下标0开始的3个长度的字符
console.log(h2);//wer
//substring截取从下标开始的元素到下标前一个元素之间的元素(左开右闭),返回字符串
let i1 = 'wertyuuiop';
let i2 = i1.substring(3,6);//从下标3到下标6(6-1)
console.log(i2);//tyu
//trim去掉字符串的前后空格,字符串的长度发生改变,一般用于登录输入框去掉验证用户名中的空格
//trimEnd去掉字符串的后空格
//trimStart去掉字符串的前空格
let j1 = ' uzi ';//长度为10
let j2 = j1.trim ()//去掉空格
console.log(j2.length)//长度为3
//toLowerCase将字符串中的所有字母转换为小写,一般用于验证码转换为统一的字符
let k1 = 'ABCDEFGHIJK'
let k2 = k1.toLowerCase();
console.log(k2);
//toUpperCase将字符串中的所有字母转换为大写,一般用于验证码转换为统一的字符
let l1 = 'abcdefghijkl'
let l2 = l1.toUpperCase ();
console.log(l2);
//toString将字符串对象转换为字符串
//valueOf将字符串对象转换为最原始的初始值
let m1 = new String("有些故事还没讲完那就算了吧");
console.log(m1);//字符串对象
console.log( m1.toString());//字符串
console.log(m1.valueOf());//初始值为字符串