Skip to content

Instantly share code, notes, and snippets.

@zeekay
Created October 29, 2012 01:24
Show Gist options
  • Save zeekay/3970861 to your computer and use it in GitHub Desktop.
Save zeekay/3970861 to your computer and use it in GitHub Desktop.
function foo(x) {
return x;
}
function bar() {
return foo.call(this, 42);
}
var calls = [];
var _call = Function.prototype.call;
Function.prototype.call = function(){
calls.push(arguments.callee.caller.name);
_call.apply(this, arguments);
}
bar();
bar();
bar();
Function.prototype.call = _call;
for (var i=0; i<calls.length; i++) {
console.log(calls[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment