1 function curry(fn, context) { 2 var args = Array.prototype.slice.call(arguments, 2); 3 return function() { 4 var innerArgs = Array.prototype.slice.call(arguments); 5 var finalArgs = args.concat(innerArgs); 6 return fn.apply(context, finalArgs); 7 }; 8 } 9 function bind(fn, context) { 10 return function() { 11 return fn.apply(context, arguments); 12 }; 13 } 14 15 //使用方法 16 var handler = { 17 message: "Event handler", 18 handleClick: function(name, event) { 19 console.log(this.message + ":" + name + ":" + event.type); 20 } 21 }; 22 23 var btn = document.getElementById("my-btn"); 24 EventUtil.addHandler(btn, "click", bind(handler.handleClick, handler, "my-btn"));