Including a stack trace when logging - console.trace
suggest changefunction foo() {
console.trace('My log statement');
}
foo();
A browser console can display it like this. Node's format is different:
My log statement VM696:1
foo @ VM696:1
(anonymous function) @ (program):1
Error.prototype.stack is a non-standard but widely available string. Engines format it differently. It is useful when you need to store or send the trace.
const e = new Error('foo');
console.log(e.stack);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents