Little JavaScript hints, episode 1: prevent console.log breakage
December 19th, 2008Here’s something I’ve tripped over in the past, and it hit me again while developing some JavaScript for freckle.
Firebug’s console.log is of great value. But don’t dare you forget it in your code before you deploy…
Here’s a quick snippet that saves your code from exploding (this is for peeps that use Prototype):
1 2 |
if(window['console'] === undefined) window.console = { log: Prototype.emptyFunction }; |
This should prevent the worst, but of course always check your code when you deploy. D’oh!
Tweet