Print call stack on Javascript
If you want to print the javascript call stack you can use:
console.log(new Error().stack);
Here it is an example:
function firstFunction() {
secondFunction();
}
function secondFunction() {
thridFunction();
}
function thridFunction() {
console.log(new Error().stack);
}
firstFunction();
//=> Error
// at thridFunction (<anonymous>:2:17)
// at secondFunction (<anonymous>:5:5)
// at firstFunction (<anonymous>:8:5)
// at <anonymous>:10:1
h/t @rondale_sc
Tweet