console.trace
Prints the chain of calls that led to this line.
Available since: Web API
Syntax
console.trace(...message)Parameters
| Parameter | Type | Description |
|---|---|---|
| ...message | any | Optional. A message before the call list. |
Return value
undefinedReturns nothing.
Examples
Who called the function (output in the browser console):
function save() {
console.trace('save called');
}
function onClick() {
save();
}
onClick();Output:
Trace: save called
at save (app.js:2)
at onClick (app.js:6)
at app.js:9Notes
It helps to find out where a function is called from when there are many callers. This example does not run on the site — open the browser console (F12).
See also
- console.error — Prints an error message — highlighted in red in the console.
- Error — The base error class: created and thrown with throw.
In the tutorial
- Debugging — How to find bugs in JavaScript: reading the error message, console.log and its variants, checking types, developer tools and debugger.