Seeing a function's code in a debugger (dynamic functions)

T

timothytoe

Is there a way in Firebug to see what code is in a function? All I can
coax out of Firefox is "function()". Same with using Firebug's
console.out.

IE's debugger just tells me it's an Object {...}.

Does anyone know of a way to see the function's code? Getting it into
a string and printing that out would be just dandy.

I'm not looking for a way to see the source (I know how to do that).
I'm changing a function during execution and trying to find a good way
to debug the result. I have my code working now, but it would have
been a lot easier with a way to see what code the function currently
has in it ready to execute.
 
T

timothytoe

you may try the toString()

Why thank you very much. I had tried it before but with the wrong
syntax (I didn't realize toString was a function, and I had left the
function-call parentheses off.

console.log(arguments.callee.toString()); works just fine to show the
contents of the current function.

Should make metaprogramming less painful for me in the future.

By the way, callee is nice, but what I really wanted was
arguments.caller, which is nonstandard and unfortunately missing in at
least one major browser. I end up doing a lot of passing of callee
down to the metafunction. "caller" would make my code a lot easier to
read and maintain. Oh well.
 

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,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top