A debugging tool is essential for JavaScript development. Firefox provides a debugger via the Firebug extension; Safari and Chrome provide built-in consoles.
Each console offers:
single- and multi-line editors for experimenting with JavaScript
an inspector for looking at the generated source of your page
a Network or Resources view, to examine network requests
When you are writing JavaScript code, you can use the following methods to send messages to the console:
console.log()
for sending general log
messages
console.dir()
for logging a browseable
object
console.warn()
for logging warnings
console.error()
for logging error messages
Other console methods are also available, though they may differ from one browser to another. The consoles also provide the ability to set break points and watch expressions in your code for debugging purposes.
Copyright Rebecca Murphey, released under the Creative Commons Attribution-Share Alike 3.0 United States license.