1、对象属性:.length为长度属性,
.toUpperCase()为大写字母文本
2、indexof函数方法返回字符串内第一次出现字符串的字符位置,字符串的位置从0开始,如果没有找到子字符串,则返回-1
3、match()方法可用来找到字符串中特定的字符,如果找到则返回这个字符,如果没有找到则返回null
4、用replace()替代字符串中的字符
Var str =”hello word!”
Document.write(str.replace(/word/,”sp”)) //是把word替换成sp
5、日期对象:
使用Date()方法可获得当日的日期
使用getTime()计算年份
6、使用concat()方法合并两个数组,形式为1.concat(2)即为把数组1和数组2合并起来
7、使用join()方法将所有数组的所有元素组成一个字符串
Join()默认的为逗号,join(.)则在所有的数组间用点号连接
8、用Boolean()检查对象是否是逻辑值,是则返回true,否则返回false;如Boolean(0)为false
9、round() 函数输出四舍五入的整数值,random()函数输出0到1之间随机的数,它们的对象均是Math,即为Math.round() Math.random()
10、正则表达式RegExp,对象有三个方法:test(),exec(),compile()
其中test()方法检索字符串中的指定值,若检测到返回值是true,没有检测到则返回false;exec()方法检索字符串中的指定值,若检测到则返回检测到的值,若没有发现,则返回null;compile()方法用于改变RegExp,如下例子:
<html>
<body>
<script type="text/javascript">
var patt1=new RegExp("e");//检索e
document.write(patt1.test("The best things in life are free"));//检索到e,输出为true
patt1.compile("d");//改变检索内容e变为d
document.write(patt1.test("The best things in life are free"));//没有检索到d,输出为false
</script>
</body>
</html>
结果为truefalse