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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Apart from the fact that
arguments.calleeis effectively being phased out and is completely absent in ECMAScript 5 strict mode, the main issue is thatFunctionobjects in IE do not have thenameproperty. 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.