2014年1月10日

call this的范围

摘要: var f1=function(){this.a="类f1的实例的a属性"};f1代表一个类;f1.a='对象f1的a属性';var f2=function(){};//类f2的实例没有a属性f2.a='对象f2的a属性';var test=function(){alert(this.a)};test.call(f1);//弹出‘对象f1的a属性’test.call(new f1());//弹出“类f1的实例的a属性”test.call(f2);//弹出“对象f2的a属性”test.call(new f2());//弹出undefined 阅读全文

posted @ 2014-01-10 16:23 学无止境2023 阅读(145) 评论(0) 推荐(0) 编辑

$.extend()

摘要: var result=$.extend({},{name:"Tom",age:21},{name:"Jerry",sex:"Boy"});合并后的结果为:result={name:"Jerry",age:21,sex:"Boy"};$.extend(hello:function(){alert('hello');});此语句的作用是把函数hello合并到jQuery的全局对象中。$.fn.extend(hello:function(){alert('hello') 阅读全文

posted @ 2014-01-10 11:23 学无止境2023 阅读(178) 评论(0) 推荐(0) 编辑

导航