var complexFunction = function(arg1, arg2) {}; var cachedFunction = cache(complexFunction); function cache(func) { return function(){ func.apply(this, arguments); for (var i = 0; i < arguments.length; i++){ console.log(arguments[i]); } };} cachedFunction('foo', 'bar'); |
argumentsis a pseudo-array, so you getarguments.calee, usesliceto convert this pseudo-var args = Array.prototype.slice.call(arguments);- Umer