how to get error stack trace in js

Solutions on MaxInterview for how to get error stack trace in js by the best coders in the world

showing results for - "how to get error stack trace in js"
Paola
06 Mar 2016
1<!DOCTYPE HTML>
2<meta charset="UTF-8">
3<title>Stack Trace Example</title>
4<body>
5<script>
6function trace() {
7  try {
8    throw new Error('myError');
9  }
10  catch(e) {
11    alert(e.stack);
12  }
13}
14function b() {
15  trace();
16}
17function a() {
18  b(3, 4, '\n\n', undefined, {});
19}
20a('first call, firstarg');
21</script>
22