摘要: 1if(typeofObject.beget!=='function'){2Object.beget=function(o){3varF=function(){};4F.prototype=o;5returnnewF();6};7}89vara={10member:true11};12varb=Object.beget(a);13vart=a.hasOwnProperty('member');14varu=b.hasOwnProperty('member');15varv=b.member;1617console.log(t);18console 阅读全文
posted @ 2012-07-18 13:02 小猩猩君 阅读(481) 评论(0) 推荐(0) 编辑
摘要: 1 Function.prototype.method = function(name, func) { 2 if (!this.prototype[name]) { 3 this.prototype[name] = func; 4 } 5 }; 6 7 Function.method('bind', function(that) { 8 //返回一个函数,调用这个函数就像它是那个对象的方法一样。 9 var method = this,10 slice = Array.prototype.slice,11 a... 阅读全文
posted @ 2012-07-18 12:37 小猩猩君 阅读(302) 评论(0) 推荐(0) 编辑