#TIL : Debug js code using console.trace

Browsers provide an useful function help you debug easier than using simple console.log function.

That is console.trace, which prints a stack trace to called function.

Example :

1
2
3
4
5
6
7
8
9
10
function foo() {
var a = 1;
bar(a);
}
function bar(x) {
console.log(x);
console.trace();
}

foo();

Comments