FireBug and JavaScript tip and gotcha | console.info()
Tuesday, October 05, 2010
If you are coding in JavaScript, and have FireBug installed into FireFox, you can print messages that are handy during development to the FireBug console.
The Tip:
You do this by adding a line like this in your JavaScript:
var x = 123;
console.info("hello world, " + x);
In the console tab in FireBug, the above will output:
hello world 123The Gotcha
When you're not debugging anymore you should delete those console.info() statements. If you neglect to do so, beyond just leaving unnecessary overhead in your code, if FireBug is closed, your JavaScript code will actually die when it reaches the first console.info() line and fail silently.

0 Comments:
Post a Comment
<< Home