js 字符串

1 。string 对象可以处理已有的字符窜对象
// 字符串可以用单引号或双引号
// 2。字符串中查找字符串:indexof()
var str1 ="hello world";
//字符串所在位置 不存在返回-1
document.write(str1.indexOf("worls"));
//字符串长度
document.write("字符串长度:"+str1.length+"<br/>");
//将字符串内容替换掉
document.write(str1.replace("world","zefeng"+"<br/>"));
//字符串大小写的替换
document.write(str1.toUpperCase());//全部大写
document.write(str1.toLocaleLowerCase());
//字符串转换为数组
var str ="z,fffffff,e,x";
var s=str.split(",");//以“,”为分隔符
document.write(s[1]);


document.write(str1.prototype);
document.write(str.constructor);

document.write()


</script>

posted @ 2015-05-19 22:13  谢小锋  阅读(105)  评论(0编辑  收藏  举报