1、toLowerCase(): 把字符串转为小写,返回新的字符串。
var str=“Hello World”;
var str1=str.toLowerCase();
console.log(str1); //hello world
2、toUpperCase(): 把字符串转为大写,返回新的字符串。
var str=“hello world”;
var str1=str.toUpperCase();
console.log(str1); //HELLO WORLD
3、charAt(): 返回指定下标位置的字符。如果index不在0-str.length(不包含str.length)之间,返回空字符串。
var str=“hello world”;
var str1=str.charAt(6);
console.log(str1);
4、charCodeAt(): 返回指定下标位置的字符的unicode编码,这个返回值是 0 - 65535 之间的整数。
var str=“hello world”;
var str1=str.charCodeAt(1);
var str2=str.charCodeAt(-2); //NaN
console.log(str1); //101
注意:如果index不在0-str.length(不包含str.length)之间,返回NaN。
补充:codePointAt():获取四字节储存的字符的编码
5、indexOf(): 返回某个指定的子字符串在字符串中第一次出现的位置
var str=“H