How to use console.log in Firebug to debug web applications

You can easily add lines of code like this:

console.log(“I like it”)

Sometimes, console.log is not available for example if you are not running Firebug or it you are not using Firefox browser. Then you can use this simple function to override console.log to avoid the Javascript error caused by non defined console.log function

// if console is not defined, e.g., Firebug console is not enabled or Non-Firefox browser if (typeof console == 'undefined') { var console = {}; console.log = function(msg) { return; }; }

Advertisement

Did you like it?

No comments yet.

Leave a Comment