0

Possible Duplicate:
Can I get the name of the currently running function in javascript?

In Javascript Is there a way I can get the name of the method/ function inside which the javascript is getting executed. I want

alert('This message is coming while running inside the method ' + GetCurrentMethodName());

0

1 Answer 1

1

Use arguments.callee.name like this:

alert('This message is coming while running inside the method ' + arguments.callee.name);
Sign up to request clarification or add additional context in comments.

7 Comments

Won't work with anonymous function assigned to method
That's because anonymous functions don't have names...
Then, this will just return an empty string.
@FlorianMargaine: Exactly. :)
sure, but I think the OP wants the method label (someobj.NAME would be NAME for example)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.