JavaScript摘录(二)

版权声明:本文为博主原创文章,转载请注明出处 http://blog.csdn.net/wxx_csdn https://blog.csdn.net/wxx_csdn/article/details/78027468

number对象

如果数字以0开头,默认为八进制,如果以0X开头,默认为十六进制

如果不是要做进制转换,不要在数字前些0

var y=0377;
var z=0xFF;

Number的精度:整数最大15位,小数位最多17位

在JS中日期对象可以直接进行比较大小

合并数组:array1.concat(array2);  这个concat类似于java中的addall

RegExp正则的三个方法

test()查找是否包含,返回true和false

exec()查找是否包含,包含返回该字符,不包含返回null

compile()设置条件,同一个声明,修改检索内容条件

var p=new RegExp("e");
document.write(p.test("eeeeeeee"));//true
p.compile("d");
document.write(p.test("eeeeeeee"));//false

JS Window

获取浏览器窗口的宽高,不包括工具栏和滚动条

<script>
	var a=window.document.body.clientHeight;
	var b=window.document.body.clientWidth;
	window.document.write(a+" , "+b);
</script>

窗口可用宽高

var c=screen.availHeight;
var d=screen.availWidth;


页面前进后退

<button type="button" onclick="history.back()">BACK后退</button>
<button type="button" onclick="history.forward()">FORWARD前进</button>

计时

setTimeout("javascript语句",1000);1s延迟后执行代码
clearTimeout();清楚setTimeout()

无穷计时,其实就是自己调自己,类似于递归

猜你喜欢

转载自blog.csdn.net/wxx_csdn/article/details/78027468
今日推荐