[UPDATED: Thursday, February 28, 2008 at 8:02:17 AM]
I thought maybe this was a tip worth blogging. I like to use labels in my debug information as it helps me to quickly identify the debug statement that generated the output. Appending a label string to a simple value is easy enough in JavaScript, as it'll automatically be converted to a string. However, this doesn't work for complex values. You can place the label on a separate line, but I like to try to keep things to one line whenever possible. The way I do this is to use an array to output my label first and then the value:
This gives you the benefit of generating a label and a value all on one line. I find the syntax very easy to read in the Firebug console and it keeps everything on one line—just the way I want it. The output will look like:
Hopefully someone else will find this tip useful.
UPDATE:For those of you who want a Firebug to output a hyperlink to the line that invoked the message, you might want to use console.debug() instead.
5 Comments
Comments for this entry have been disabled.