Javascript exception stack trace


In Firefox I can get the stack trace of an exception by using exception.stack.

Is there a way to get that in other browsers, too?

Edit: I actually want to save the stack trace automatically (if possible) and not debug it at the time (i.e. I know how to get the stack trace in a debugger).

Best Solution

Place this line where you want to print the stack trace:

console.log(new Error().stack);

Note: tested by me on Chrome 24 and Firefox 18

May be worth taking a look at this tool as well.