[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Error/stack [Back]  [Original]

Error.prototype.stack - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

Error.prototype.stack

:

Error

@ Error

Firefox Safari 6+ Opera 12- JavaScript V8 ChromeOpera 15+ IE 10+ error.stack

Firefox 14 (Firefox bug 744842) @ string "[object Object]" Firefox 14 arguments.callee.caller.arguments arguments.callee.caller.name "undefined" "(void 0)" "@", "(", ")" Firefox 14

Firefox Error PhantomJS ErrorMSDN docs PhantomJS

html stack

html
<!doctype html>
<meta charset="UTF-8" />
<title>Stack Trace Example</title>
<body>
  <script>
    function trace() {
      try {
        throw new Error("myError");
      } catch (e) {
        alert(e.stack);
      }
    }
    function b() {
      trace();
    }
    function a() {
      b(3, 4, "\n\n", undefined, {});
    }
    a("first call, firstarg");
  </script>
</body>

Windows C:\example.html

Firefox 30 (Firefox bug 762556):

trace@file:///C:/example.html:9:17
b@file:///C:/example.html:16:13
a@file:///C:/example.html:19:13
@file:///C:/example.html:21:9

Firefox 14 to Firefox 29:

trace@file:///C:/example.html:9
b@file:///C:/example.html:16
a@file:///C:/example.html:19
@file:///C:/example.html:21

Firefox 13

Error("myError")@:0
trace()@file:///C:/example.html:9
b(3,4,"\n\n",(void 0),[object Object])@file:///C:/example.html:16
a("first call, firstarg")@file:///C:/example.html:19
@file:///C:/example.html:21

Stack of eval'ed code

Firefox30 Gecko 30 Function() eval() "> Function" eval "> eval"Firefox bug 332176.

js
try {
  new Function("throw new Error()")();
} catch (e) {
  console.log(e.stack);
}

// anonymous@file:///C:/example.html line 7 > Function:1:1
// @file:///C:/example.html:7:6

try {
  eval("eval('FAIL')");
} catch (x) {
  console.log(x.stack);
}

// @file:///C:/example.html line 7 > eval line 1 > eval:1:1
// @file:///C:/example.html line 7 > eval:1:1
// @file:///C:/example.html:7:6

Firefox //# sourceURL eval Firefox eval //# sourceURL eval


Web Proxy Viewer  |  New URL  |  Original Page