var Event = { on: function (eventName, callback) { if (!this[eventName]) { this[eventName] = []; } this[eventName].push(callback); }, emit: function (eventName) { var that = this; var params = arguments.length > 1 ? Array.prototype.slice.call(arguments, 1) : []; if (that[eventName]) { Array.prototype.forEach.call(that[eventName], function (arg) { arg.apply(self, params); }); } } }