匀强电场 level
获赞
3
粉丝
0
关注
0
看过 TA
1
浙江工业大学
2018
前端工程师
IP属地:未知
暂未填写个人简介
私信
关注
var Event = {   on: function(eventName, callback){   //todo   if(!this[eventName])   this[eventName] = [];   this[eventName].push(callback);   },   emit: function(eventName){   //todo   if(this[eventName])   Array.prototype.forEach.call(this[eventName], function(func){   func.call(this);   });   }  ...
五行缺心:涉及兼容性和参数问题 var Event = {    on : function(eventName, callback){        this[eventName] = this[eventName] || new Array();        this[eventName].push(callback);    },    emit : function(eventName){      if(this[eventName]){        var i, func;        for(i = 0; func = this[eventName][i]; i++){          if(func.length <= 0){            func.call(this);          }else{            var args = Array.prototype.slice.call(arguments, 1);            func.apply(this, args);          }        }      }else{        return console.log(undefined);      }    } }
投递网易等公司7个岗位
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客网在线编程
牛客网题解
牛客企业服务