摘要: function Observer() { this.fns = [];}Observer.prototype = { subscribe: function (fn) { this.fns.push(fn); }, unsubscribe: function (fn) { this.fns = this.fns.filter( function (el) { if (el !== fn) { ... 阅读全文
posted @ 2013-04-17 11:18 黑暗骑士之“闪” 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 当我们勇气prototype的时候会发现必须要new 一下才能去调用,对此感觉又点小小不爽下面在鬼群讨论的时候,一个群友提出了一个比较好的方法巧避new下面就是一些主要代码:var calendar=function(){ return calendar['init'].apply(calendar,arguments)}(function(exports,global){exports.init=function(){ console.log(1)}exports.show=function(){ console.log(2)}exports.getList=functio. 阅读全文
posted @ 2013-04-17 10:55 黑暗骑士之“闪” 阅读(146) 评论(0) 推荐(0) 编辑