![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
js
若寒hqq
大学生,自学web开发
展开
-
js笔试题
可以看出赋值语句是从前向后的顺序,先给foo.x赋值,然后给foo重新赋值,所以最后foo是{n:2},foo.x-->undefined console.log('one'); setTimeout(function() { console.log('two'); }, 0); console.log('three');这个考察的对闭包和毁掉函数的理解,setTimeout函数中有原创 2015-08-23 16:20:19 · 867 阅读 · 0 评论 -
JS修改元素样式
var obj = document.getElementById('test'); if (window.getComputedStyle){ style = window.getComputedStyle(obj, null); // 非IE }else{ style = obj.currentStyle; // IE } console.log原创 2015-10-15 17:09:18 · 456 阅读 · 0 评论 -
prototype和__proto__
function Person(name){ this.name = name; } Person.prototype.hi = function(){ console.log("hi", this.name); } function Student(name,age){ Person.call(this, name, age); this.age = ag原创 2015-10-09 19:03:47 · 341 阅读 · 0 评论 -
js克隆对象
为什么要有克隆方法呢?因为JS中的对象赋值不像C,C++那样,新开辟一个空间,而是直接指向那个对象的引用,两个值会互相影响。 如下图: 克隆对象的方法 1.如果是对象,得将其属性一个一个赋值过去 clone: function(obj){ if(this.isArray(obj)){ var arr = []原创 2015-10-10 10:46:32 · 550 阅读 · 1 评论 -
浏览器渲染原理
各个浏览器都有他们的原理,但都有一定的规范。 1.当浏览器初次加载文档时,浏览器引擎会解析HTML文档成为DOM树。 2.之后根据DOM元素的几何属性构建一颗能够渲染的树。(渲染树不包括隐藏节点) 3.渲染树构建完成后,浏览器就将其放入正确的位置了。 4.根据给出的样式来绘制出页面。原创 2015-09-15 09:31:58 · 306 阅读 · 0 评论 -
前端性能优化篇(常见)
1.DOM篇 1)DOM添加优化:createDocumentFragment() var oFragment = document.createDocumentFragment(); for(var i = 0 ; i < 10; i ++) { var p = document.createElement("p"); var oTxt = document.createTe原创 2015-09-14 17:04:07 · 362 阅读 · 0 评论 -
js ajax
function ajax(options){ var defaults = { url: '', type: 'POST', data: {}, username: '',原创 2015-10-16 22:09:41 · 355 阅读 · 0 评论 -
js跨域问题
什么是跨域? 概念:只要协议、域名、端口有任何一个不同,都被当作是不同的域。 简单明了,不明白的话可以百度百科,额。。。。。。 1.document.domain(跨子域) 这个是范围最小的一个。 比如a.example.com 中写了一个iframe,其中src="example.com",但是因为是不同域的就无法写js获取iframe中的document等。 这时设置docum原创 2015-09-03 22:41:28 · 314 阅读 · 0 评论 -
多级下拉菜单插件
刚写了一个多级下拉菜单插件,如果要用可以去我的github看哦。 https://github.com/hqqxxf/test#多级下拉菜单插件原创 2015-08-07 10:36:31 · 904 阅读 · 0 评论 -
js笔试题
f = function() {return true;}; g = function() {return false;}; (function() { if (g() && [] == ![]) { f = function f() {return false;}; function g() {return true;} } })(); cons原创 2015-08-18 17:14:01 · 1285 阅读 · 0 评论 -
uuid (guid)全局唯一标识符
function uuid() { var s = []; var hexDigits = "0123456789abcdef"; for (var i = 0; i < 36; i++) { s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); } s[14] = "4"原创 2015-08-02 12:04:06 · 633 阅读 · 0 评论