Michael Levin | Wednesday, April 20, 2011
Here are some tools I recommend:
Chrome Developer Tools
If breakpoints are not your debugging tool of choice, both Chrome and Firefox (with Firebug) support adding debugging statements to your code that get output to the console. To do this, simply use
console.debug() and pass the variable you want to examine as a parameter.
Chrome has gone a step further and provided a few new console methods for you to use. One of these is
console.assert(). This method is passed some condition as a parameter, which when evaluated to false, will print a complete stack trace. This can be very useful for validating any invariants in your code. Also, if you want to see a stack trace at any point in the program, you can now throw in a call to
console.trace(). These new additions to Chrome, as well as some others, were explained in greater detail earlier today in a post on the Chromium blog.
If you just want to try it out on a simple static site, look at the example provided in the Jasmine GitHub repository. Once you have all the files downloaded, you can just edit the
SpecRunner.html in your browser.