Created
October 29, 2012 01:24
-
-
Save zeekay/3970861 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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