obj.resend = function() { var pof = Object.getPrototypeOf; var has = function() {......} // hasOwnProperty的封装 var make = function(obj, old) { return function(name, args) { var step = pof(obj), r; while (step && !has(step, name)) step = pof(step); if (!step) throw new Error('Unable to resend: method missing');
var foundMethod = step[name]; var backup = arguments.callee; this.resend = make(this, backup); r = foundMethod.apply(this, Array.prototype.slice.call(arguments, 1)); this.resend = old; return r } };
return function(name, args__) { var rv; var old = this.resend; this.resend = make(this, old); rv = this.resend.apply(this, arguments); this.resend = original; return rv; } }()