console.log() problem solved

console.log(),  console.debug()..  my two favourite helpers. If I need check whether my jquery selector returns what I expect it to or just to check how some variable changes its value during script execution I often use console.  It’s great tool. Google Chrome provides it by default, Firefox only when you have Firebug turned on and IE likewise. If there is no console object available, then Javascript throws an Error and stops execution. Console should be used in developement enviroment only, where you can be sure that console is turned on. But sometimes it is good to keep it, at least for error messages. I don’t know about any tool which would walk thru javascript code and remove calls to console when it is deployed in production. If you know about any, please let me know in comments.  As a workaround I wrote simple script which mocks console to prevent errors:

Consolecheck.js

// if console is not available -> mock it to prevent errors
try {
    var c = console;
}
catch (e) {
    console = {};
    console.log = function () { };
    console.debug = function () { };
    console.warn = function () { };
    console.error = function () { };
    console.dir = function () { };
}
Buffer
GetSocial