Get to know MDN better
Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.
Note: The stack property is de facto implemented by all major JavaScript engines, and the JavaScript standards committee is looking to standardize it. You cannot rely on the precise content of the stack string due to implementation inconsistencies, but you can generally assume it exists and use it for debugging purposes.
The non-standard stack property of an Error instance offers a trace of which functions were called, in what order, from which line and file, and with what arguments. The stack string proceeds from the most recent calls to earlier ones, leading back to the original global scope call.
A string.
Because the stack property is non-standard, implementations differ about where it's installed.
| Writable | yes |
| Enumerable | no |
| Configurable | yes |
Each JavaScript engine uses its own format for stack traces, but they are fairly consistent in their high-level structure. Every implementation uses a separate line in the stack to represent each function call. The call that directly caused the error is placed at the top, and the call that started the whole call chain is placed at the bottom. Below are some examples of stack traces:
V8 provides the non-standard stack trace API for customizing the stack trace, including Error.captureStackTrace(), Error.stackTraceLimit, and Error.prepareStackTrace(). Other engines support this API to varying extents.
Different engines set this value at different times. Most modern engines set it when the Error object is created. This means you can get the full call stack information within a function using the following:
Without having to throw an error and then catch it.
Stack frames can be things other than explicit function calls, too. For example, event listeners, timeout jobs, and promise handlers all begin their own call chain. Source code within eval() and Function constructor calls also appear in the stack:
In Firefox, you can use the //# sourceURL directive to name an eval source. See the Firefox Debug eval sources docs.
The following script demonstrates how to use the stack property to output a stack trace into your browser window. You can use this to check what your browser's stack structure looks like.
Not part of any standard.
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 19, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.