Search code examples
javascriptjquerycross-browsermootools

Does Internet Explorer support arguments.callee.name?


I know I can get the name of the current running function by using

arguments.callee.caller.name

But this does not work in Internet Explorer (any version). What's the correct cross-browser syntax? Does a workaround exist?


Solution

  • Apart from the fact that arguments.callee is effectively being phased out and is completely absent in ECMAScript 5 strict mode, the main issue is that Function objects in IE do not have the name property. It is implemented in some browsers, notably Firefox and recent WebKit-based browsers, but is non-standard, and indeed there is no standardized way to get hold of a function name.

    The only option this leaves you is trying to parse the name from the function's string representation, which is not a good idea. There's a (long) discussion here about it: http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/b85dfb2f2006c9f0.