February 2010 (1)
September 2009 (1)
May 2009 (1)
April 2009 (1)
March 2009 (4)
January 2009 (3)
November 2008 (2)
October 2008 (2)
September 2008 (1)
August 2008 (5)
July 2008 (3)
June 2008 (1)
May 2008 (5)
April 2008 (8)
March 2008 (3)
February 2008 (1)
January 2008 (2)
December 2007 (2)
November 2007 (4)
October 2007 (17)
September 2007 (9)
Using Firebug’s console without fear
Thursday, February 04 2010
I love Firebug, and I especially love sprinking console.log calls around the place, but I hate the way things break when you forget to remove them and your code hits a browser without Firebug installed.
if (typeof console === 'undefined') {
var console = {}; // For once not having block scoping is kind of handy
console.log = function () {};
};
console.log("It's safe to use console.log");
I feel there ought to be a smarter way of doing this but I just can’t think of one.
Tags: javascript ~ firebug ~ catalyst
Rendered at 2010-09-04 07:44:47