字符串方法
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>字符串</title>
</head>
<body>
</body>
<script type="text/javascript">
var a="世间纵有千万曲,人间再无黄家驹";
var b=a.substr(0,5);
document.write(b+"<br />");
var a="你终归会化为尘土";
var b=a.substring(0,5);
document.write(b+"<br />");
b = a.slice(2,5);
document.write("b = " + b+"<br />");
b= a.slice(-3);
document.write("b = " + b+"<br />");
b=a.slice(1);
document.write("b="+b+"<br />");
var str="my hert is broken";
var index=str.indexOf("i");
document.write("index="+index+"<br />");
var str="my hert is broken";
var index=str.lastIndexOf('e');
document.write("index="+index+"<br />");
var str="Hello world!";
document.write(str.charAt(1)+"<br />");
var a="wo zui xin teng de ren";
var b=a.charAt(8);
document.write(b+"<br />");
var a="wo zui xin teng de ren";
var b=a.charCodeAt(8);
document.write(b+'<br />');
document.write(String.fromCharCode(72,69,76,76,79));
document.write("<br />");
document.write(String.fromCharCode(65,66,67)+'<br />');
var str = "how are you doing today!";
console.log(typeof str);
var a = str.split(" ");
document.write(a+'<br />');
var a = str.split("");
document.write(a+'<br />');
var a = str.split(" ",3);
document.write(a+'<br />');
var str="Hello World!";
document.write(str.toLocaleLowerCase()+'<br />');
var str="Hello World!";
document.write(str.toLocaleUpperCase()+'<br />');
var str = "nnd,今天还要上班呢!sb领导,tmd领导!TMD领导 ";
str = str.replace(/(nnd|sb|tmd)/gi,"***");
document.write(str);
</script>
</html>