创建string的方法
var str ="abc"; var str = new String("abc"); var str = String("abc');
length 属性方法
indexOf replace charAt split
<html> <head> <script typt="text/javascript"> var str="abcdefghi"; alert(str);//abcdefghi alert(str.charAt(0));//a var str1="aaa"; var str2="bb"; var str3="cc"; alert(str1.concat(str1,str2,str3));//abbcc alert(str1.indexOf("a",0)); alert(str.replace("a","lll")); var arr = str.split(""); for(var i=0;i<arr.length;i++){alert(": "+arr[i]);} </script> </head> <body> </body> </html>
substr boUpperCase toLowerCase
var str="abcdefghi"; alert(str.substr(0,2));//ab alert(str.substr(1,3));//bcd alert(str.toUpperCase());//ABCDEFGI alert(str.toLowerCase());//abcdefgi