标签:
Boolean、Number、Object
function对象
另一种写法:
var add=new Function("x","y","return(x+y)");
arguments属性:实参数组
Math对象
提供科学函数和常数
属性:
E PI等
方法:
abs求绝对值 ceil(向上取整) floor(向下取整) round(四舍五入) pow(a,b)(返回a的b次方) random sqrt(求平方根)
String对象
属性:
length
方法:
charAt concat indexOf lastIndexOf replace(reExp,replaceText) search(rgExp) split substr(start[,length]) substring(start,end) toLowerCase toUpperCase valueOf()
match(rgExp)(使用正则表达式模式对字符串进行查找,并将查找的结果作为数组返回)
RegExp对象
RegExp对象不能直接创建,但是始终可以使用。在成功的的正则表达式查找前的初始的各个属性值为:
index -1
lastIndex -1
lastMatch ""
属性:
input:最后查找的字符串
index:查找的第一个匹配的开始的下标
lastIndex:下一个满足条件的匹配项开始的下标,如果没有下一个匹配项,返回-1
lastMatch:返回最后匹配的字符串
leftContext:返回字符串开始位置到字符串最后匹配位置前的字符串
rightContext:返回字符串第一次匹配结束位置到字符串结尾字符
RegExp正则表达式对象
构造:
re=/pattern/[flags]
re=new RegExp("pattern",["flags"])
参数:
re:正则表达式变量名
pattern:使用的正则表达式模式
flag:使用标志
g:全文查找所有出现的pattern
i:忽略大小写
m:多行查找
方法:
rgExp.complie(pattern,[flags]);将正则表达式编译成为内部格式,从而执行得更快,返回正则表达式对象
rgExp.exec(str):用正则表达式在字符串中运行查找,并返回包含查找对象的一个数组
<html>
<head>
</head>
<body>
</body>
</html>
<script>
var f1=new Function("a","b","return (a+b)");
//alert(f1(2,3));
//alert("PI:"+Math.PI);
//alert("E:"+Math.E);
//alert(Math.abs(-1));
//alert(Math.ceil(1.23));
//alert(Math.floor(1.67));
//alert(Math.round(1.45));
//alert(Math.sqrt(4));
//alert(Math.pow(2,3));
var s=new String("gjhdgsjkdgsjgfs");
//alert(s.length);
//alert(s.charAt(3));
//alert(s.concat("hlkhk"));
//这里出错了
var re=/"jh"/g;
re = new RegExp("jh","g");
//alert(s.replace(re,h));
alert(re.index);
</script>
标签:
原文地址:http://www.cnblogs.com/aigeileshei/p/5615916.html