1.String对象
String对象用于处理已有的字符串
字符串可以使用单引号或双引号
2.在字符串中查找字符串:indexof()
<script>
var str = "hello world";
//indexof() 返回已存在字符串的位置
document.write(str.indexOf("hello"));//这里返回为:0
document.write(str.indexOf(" "));//这里返回为:5
document.write(str.indexOf("world"));//这里返回为:6
</script>
3.内容匹配:match()
<script>
var str = "hello world";
//match() 匹配字符串位置,存在返回匹配值,不存在返回null
document.write(str.match("world"));//这里返回为:world
document.write(str.match("world1"));//这里返回为:null
</script>
4.替换内容:replace()
<script>
var str = "hello world";
//replace() 替换原有的字符串并返回替换后的字符串
document.write(str.replace("World","csdn"));//这里返回:hello csdn
</script>
5.字符串大小写的转换:toUpperCase() / toLowerCase()
<script>
var str = "hello world";
//toUpperCase()将字符串全部转化成大写
document.write(str.toUpperCase());//这里返回:HELLO WORLD
//toUpperCase()将字符串全部转化成小写
document.write(str.toLowerCase());//这里返回:hello world
</script>
6.字符串转化为数组:strong>sqlit()
<script>
var str = "hello world";
var str1 = "hello,csdn";
//split() 对字符串的分隔标识符进行选择,str是" "空格,str1是","逗号
var s = str1.split(",");
document.write(s[1]);//这里返回:csdn
</script>
7.字符串大部分的属性和方法:
1.属性:length、prototype、constructor
2.方法:charAt()、charCodeAt()、concat()、fromCharCode()、indexOf()、lastIndexOf()、match()、replace()、search()、substring()、substr()、valueOf()、toLowerCase()、toUpperCase()、split()