JavaScript Console Including a stack trace when logging - console.trace()


function foo() {
  console.trace('My log statement');


Will display this in the console:

My log statement       VM696:1
  foo                  @ VM696:1
  (anonymous function) @ (program):1

Note: Where available it's also useful to know that the same stack trace is accessible as a property of the Error object. This can be useful for post-processing and gathering automated feedback.

var e = new Error('foo');