Stack traces: Difference between revisions

→‎{{header|JavaScript}}: The provided example code only shows the error message (e.g. "new Error('foo')" would display "foo", not the desired output)
(→‎{{header|JavaScript}}: The provided example code only shows the error message (e.g. "new Error('foo')" would display "foo", not the desired output))
Line 381:
{{works with|Opera}}
{{untested|JavaScript}}
If the option at ''opera:config#UserPrefs|ExceptionsHaveStacktrace'' is enabled, uncaught exceptions will show their stack trace in the error console.
<lang javascript>try {
 
throw new Error;
} catch(e) {
alert(e.message);
}</lang>
The following version works in many browsers but it infinitely loops when there is recursion:
<lang javascript>function foo () {
Anonymous user