1.字符串的常用方法
var str = 'hello world';
var result = str.charAt(1);
document.write(result);
var str = 'Frankenstein';
var result = str.charCodeAt(3);
var result1 = str.charCodeAt(23);
console.log(result);
console.log(result1);
var str = "heHELLO WORLD";
var newStr = str.toUpperCase();
var newStr1 = str.toLowerCase();
console.log(newStr);
console.log(newStr1);
var str = 'The Three FireGuners';
var result = str.substring(4, 9);
var result1 = str.substring(9, 4);
如出现第一个参数大于第二个参数的情况,subString()会自动变更两个参数的位置
console.log(result);
console.log(result1);
var str = 'hello sxt! gongbye sxt';
var newStr = str.replace('sxt', 'xxx');
console.log(newStr);
console.log(str);
var str = 'hello sxt !goodbye sxt';
console.log(str.split(""));
"t", " ", "!", "g", "o", "o", "d", "b", "y", "e", " ", "s", "x", "t"]
console.log(str.split(' '));