Monday 10 September 2012

Console.trace() to debug javascript

The following is taken from the firebug wiki:

Console.trace() prints an interactive stack trace of JavaScript execution at the point where it is called.
The stack trace details the functions on the stack, as well as the values that were passed as arguments to each function. You can click each function to take you to its source in the Script tab, and click each argument value to inspect it in the DOM or HTML tabs.

We have all been there struggling to fix javascript bugs - we know where they break, but take ages working out what called that function causing in to break. Console.trace() allows us to view the full stacktrace and more easily debug our code.

Post your own experiences in the comments below!

No comments:

Post a Comment