Saturday, June 16, 2012

[JScript] The name of the current function

This is a plug for StackOverflow, where I spend a fair bit of time.

Today I went looking for Javascript code to give me the name of the currently executing function. I found answers
here and here. And now I have the following in my script:

var fname = arguments.callee.toString().split(/ /)[1].split(/\(/)[0];

Woe betide if callee is ever disabled!

© Copyright Bruce M. Axtens, 2012

No comments: