0

I'm using a log function to debug in the console. I want to know what function I'm logging from in the browser console. I don't want to use the debugger.

function doSomething() {}

console.log(doSomething.name);

Basically I want the name property from Function.name with out knowing what doSomething is. Is this possible?

Is there some component of JS that tracks what function I'm in and that I have access to.?

  • It seems like you're looking to print the stack. [This](http://stackoverflow.com/questions/591857/how-can-i-get-a-javascript-stack-trace-when-i-throw-an-exception) may help – master565 Jun 21 '16 at 15:56
  • 4
    Possible duplicate of [Can I get the name of the currently running function in JavaScript?](http://stackoverflow.com/questions/1013239/can-i-get-the-name-of-the-currently-running-function-in-javascript) – plasmid87 Jun 21 '16 at 15:57
  • You could also modify the stacktrace to help you out : http://stackoverflow.com/a/635852/1606432 – Pogrindis Jun 21 '16 at 16:01
  • I would have thought there would be something on `this` and not `arguments`, but I don't see anything that references that. –  Jun 21 '16 at 16:12

0 Answers0