Forum Discussion
If you're writing in JavaScript... have you thought about using function.caller?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller
- tristaanogre6 years agoEsteemed Contributor
I tried this experiment... and here's what I got.
I created the following code:function root(){ Log.Message(root.caller); } function oneUp(){ Log.Message(oneUp.caller); root(); } function twoUp(){ Log.Message(twoUp.caller); oneUp(); } function top(){ Log.Message(top.caller); twoUp(); }
I then ran the top function. My test log, on completion, looks like this.
If you replace <function>.caller with <function>.caller.name you get just the name of the calling function.
- RUDOLF_BOTHMA6 years agoCommunity Hero
We use Jscript. I have tried a direct implementation of the Javascript call as you suggested, since they are theorhetically just about interchangeable. I have tried .caller before, but it appears there are some differences though.
It doesn't encounter errors. It can't pick up the caller though - it's just null
I thought you'd find it amusing that I also tried ObsoleteFunction().caller - and ended up with a Stackoverflow, doh !
- RUDOLF_BOTHMA6 years agoCommunity Hero
Just to be clear. The call stack would be a nice to have, not a critical - I could use the page picture if needs be (it might slow down the tests massively, so will only add the picture if I have my verbose logging project variable as true :smileyvery-happy:). I won't be spending much time on this myself if it's not a trivial implementation .
Related Content
- 5 years ago
- 13 years ago
Recent Discussions
- 2 days ago