gistfile1.txt 一些常见操作字符串var str="hello world";//document.write(str.indexOf("world"));//返回所在位置//document.write(str.match("world"));//匹配//document.write(str.replace("world","二傻"));//替换//document.write(
一些常见操作
字符串
var str="hello world";
//document.write(str.indexOf("world"));//返回所在位置
//document.write(str.match("world"));//匹配
//document.write(str.replace("world","二傻"));//替换
//document.write(str.toUpperCase());
//document.write(str.toLowerCase());//大小写
//var str="hello,xixi,erya";
//var s=str.split(",");//定义分割线
//document.write(s[1]);
数组
//var a=["hello","world","d","c","b","a"];
//var b=["xixi","erya"];
//var c=a.concat(b);//合并
//document.write(c);
//document.write(a.sort());//排序
//document.write(a.sort(function(a,b){
//return b-a;
//}));//倒序
//b.push("keke");//追加
//document.write(b);
//var a=["c","b","a"];
//document.write(a.reverse());//翻转
//document.write(Math.round(2.5));//四舍五入
//document.write(Math.random()*10);//0-1(*10)的随机数
//document.write(parseInt(Math.random()*10));//设置成整数
//document.write(Math.max(10,20,30));
document.write(Math.abs(-10));//绝对值
