摘要: **十进制转换为二进制:** ```js var num = 100; console.log(num.toString(2)); ``` toString()方法可把一个 Number 对象转换为一个字符串,并返回结果。 **语法** ``` NumberObject.toString(radix); ``` 其中,radix为可选。规定表示数字的基数,使 2 ~ 36 之间的整数。若省略该参数,则使用基数 10。但是要注意,如果该参数是 10 以外的其他值,则 ECMAScript 标准允许实现返回任意值。 阅读全文
posted @ 2016-11-30 15:35 豫见世家公子 阅读(1924) 评论(0) 推荐(0) 编辑
摘要: 以下为js获取HTTP的全部请求头信息: ```js var req = new XMLHttpRequest(); req.open('GET', document.location, false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); console.log(headers); ``` 以下为js获取HTTP的部分请求头信息,如日期: ```js var req = new XMLHttpRequest(); req.open('GET', document.location, false); req.send(null); var headers = req.getResponseHeader('date'); console.log(headers); 阅读全文
posted @ 2016-11-30 14:54 豫见世家公子 阅读(2852) 评论(0) 推荐(0) 编辑