Get name of calling function...

H

hzgt9b

Given a currently executing function is there a cross browser way to
get (1) the name of the calling function (assuming there is one) and
(2) the name of the current function?

I've see references to (depricated) arguments.callee - but that
doesn't work in IE.

Your input appreciated
 
J

Joost Diepenmaat

hzgt9b said:
Given a currently executing function is there a cross browser way to
get (1) the name of the calling function (assuming there is one) and
(2) the name of the current function?

I've see references to (depricated) arguments.callee - but that
doesn't work in IE.

arguments.callee isn't deprecated, and it works in IE too, but a
somefunction.name isn't standard, and IE doesn't appear to support it.
Your input appreciated

You may be able to hack on arguments.callee.toString() and
thisFunction.caller.toString().
 
T

Thomas 'PointedEars' Lahn

hzgt9b said:
Given a currently executing function is there a cross browser way to
get (1) the name of the calling function (assuming there is one) and
(2) the name of the current function?

Functions are objects. Objects don't have names by default, they have
identity. In a function declaration, you also declare a property of an
Variable Object to refer to the Function object created by the declaration.
However, this function can be called using references that are values of
other properties with other names. The same goes for Function objects
created using other means.
I've see references to (depricated) arguments.callee - but that
doesn't work in IE.

arguments.callee is *not* _deprecated_ and it works in IE. You are
confusing this with Function.prototype.arguments.callee.


PointedEars
 
H

hzgt9b

arguments.callee isn't deprecated, and it works in IE too, but a
somefunction.name isn't standard, and IE doesn't appear to support it.


You may be able to hack on arguments.callee.toString() and
thisFunction.caller.toString().

Thanks for your replies
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top