function foo() {
bar();
}
function bar() {
baz();
}
function baz() {
console.log(new Error().stack);
}
foo();Error.prototype.stack / notebook
Error.prototype.stack
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
function foo() {
console.log(new Error().stack);
}console.log(new Function("return new Error('Function failed')")().stack);
console.log("====");
console.log(eval("new Error('eval failed')").stack);