Easy way to write messages in javascript console without firebug

Very simple solution w/o any prerequisites. No need to install anything like firebug or javascript library to log activities.

function writeLog(log) {
    setTimeout(function() { throw new Error(log); }, 0);
}

The javascript exceptions are automatically caught in the console, thus forcing an error writes into the console. In order to not brake any js execution use setTimeout to run the error into another thread.

No comments:

Post a Comment