files/en-us/web/api/console/trace_static/index.md
{{APIRef("Console API")}} {{AvailableInWorkers}}
The console.trace() static method outputs a stack trace to the console.
[!NOTE] In some browsers,
console.trace()may also output the sequence of calls and asynchronous events leading to the currentconsole.trace()which are not on the call stack — to help identify the origin of the current event evaluation loop.
See Stack traces in the {{domxref("console")}} documentation for details and examples.
console.trace()
console.trace(object1, /* …, */ objectN)
objects {{optional_inline}}
None ({{jsxref("undefined")}}).
function foo() {
function bar() {
console.trace();
}
bar();
}
foo();
In the console, the following trace will be displayed:
bar
foo
<anonymous>
{{Specifications}}
{{Compat}}