console.trace
prints a stack trace to the console, showing the path your code took to reach the current point. This is particularly useful for tracking down the origin of errors or unexpected behavior.
function functionA() {
functionB();
}
function functionB() {
console.trace('Trace');
}
functionA();
// Output:
// Trace
// at functionB (<anonymous>:6:11)
// at functionA (<anonymous>:2:3)
// at <anonymous>:9:1