CKTIS / JavaScript
console.trace() — call stack trace
console.trace() displays the stack at the call site, helping you discover how execution reached it.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
console.trace(...data)console.trace(...data) prints a representation of the current call stack. Printing the trace does not require throwing an exception. If the call completes normally, it returns undefined and execution continues. However, formatting an argument can invoke user-defined conversion code that throws an exception.
Arguments are optional; the implementation may format them as a label. Stack presentation and function names are implementation-defined and may differ from new Error().stack.
The Console Standard defines this API, not an ECMAScript edition. It specifies no minimum browser versions; Node 24 does not establish browser support.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>console.trace example</title>
</head>
<body>
<main><pre id="result"></pre></main>
<script>
const result = document.getElementById('result');
function start() {
inspect('checkpoint');
}
function inspect(label) {
console.trace(label);
const next = 'continued';
console.log(next);
result.textContent = `Console trace: ${label}\nLook for ${inspect.name} above ${start.name} in the stack.\nNext console log: ${next}`;
}
if (typeof console.trace === 'function') {
start();
} else {
result.textContent = 'console.trace is unavailable.';
}
</script>
</body>
</html>Result
Console trace: checkpoint Look for inspect above start in the stack. Next console log: continued
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.