<script>
let stack = new Error().stack;
console.log(stack);
</script>
All browsers return a string delimited by a \n. Assuming the file full path is http://localhost/yalog/experiments.html and code in the file is similar to:
function first() {
second();//line 17
}
function second() {
const stack = new Error().stack;//line 21
console.log(stack);
}
first();//line 28
Chrome/Opera returns e.g. this:
Error at second (http://localhost/yalog/experiments.html:21:31) at first (http://localhost/yalog/experiments.html:17:17) at http://localhost/yalog/experiments.html:28:9
Firefox:
second@http://localhost/yalog/experiments.html:21:31 first@http://localhost/yalog/experiments.html:17:17 @http://localhost/yalog/experiments.html:28:13